Image

Imagepkbarbiedoll wrote in Imagephp

Strip all whitespace characters except ' ' (space)

I need to remove the leading and trailing whitespace and line returns from the following variable:

$section_description = "
   
asdf test one two three

";
The following removes -all- whitespace:
$section_description    = preg_replace('/\s+/','',$section_description);

echo $section_description;
asdftestonetwothree

This has no effect:
$section_description    = preg_replace('/ \t\n\x0B\f\r+/','',$section_description);


echo $section_description;
   
asdf test one two three

 
I read that \s is synonymous with \t\n\x0B\f\r.  But that doesn't appear to be the case, or I'm misunderstanding something..

Any help?