by @CodingExample

How to remove whitespaces from a string in PHP

Home » php » How to remove whitespaces from a string in PHP

To remove all whitespaces from a string, we can use the str_replace() method in PHP.

Here is an woking code example:

$str = str_replace(" ","", "hello you can see me without spaces");
echo $str;

Output:

helloyoucanseemewithoutspaces

References