string - str_replace problem in php -


i want strip spaces not between 2 words? script says all:)

$string = "              bah bah    bah  "; $string = str_replace("/w /w", "+", $string); // want string this: $string = "bah+bah+bah";  

the idea want rid of unnecessary spaces(not @ beginning , end)

can not trim whitespace , use urlencode() convert interior spaces +? if have other characters cannot tolerate being url encoded, not work. don't know full requirements.

urlencode(trim($string));   $string = "              bah bah"; echo urlencode(trim($string));  // bah+bah 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -