Sandhurst Sandhurst - 5 months ago 24
PHP Question

Replace   with a blank or empty string PHP

Well, I have tried these and it seems that none of them are working, my example string is

$text_description="      Hello world! lorel ipsum";

$text_description= str_replace(" "," ",$text_description);
$text_description = preg_replace("/&#?[a-z0-9]+;/i"," ",$text_description);
$text_description=html_entity_decode($text_description);

Answer
$text_description="       Hello world! lorel ipsum";
$text_description = str_replace(' ', ' ', $text_description);
echo $text_description;

Output:

Hello world! lorel ipsum