To replace blanks in a string in PHP you can use the following snippet.

Sample PHP

$stringOne = "This is a Test!";  
$stringTwo = str_replace(" ", "", $stringOne);  

2 thought on “How to replace blanks in a string in PHP”

Leave a Reply