remove all space between the string in php code example Example: remove every whitespace php $string = preg_replace('/\s+/', '', $string);