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
Post a Comment