I want to strip all spaces that are not between two words? The script says it all:)
$string = " bah bah bah ";
$string = str_replace("/w /w", "+", $string);
// i want string to look like this:
$string = "bah+bah+bah";
The idea is that i want to get rid of all unnecessary spaces(not only at the beginning and end)
Can you not just trim whitespace and use
urlencode()to convert the interior spaces to+? If you have other characters which cannot tolerate being url encoded, this will not work. But we don’t know your full requirements.