str replace - strip all unnecessary spaces in a php string -


i want strip spaces not between 2 letters:

$string = "              bah    bah    bah bah  "; $string = str_replace("/w /w", "+", $string); // goes here? this: $string = "bah+bah+bah+bah";  

the idea want rid of unnecessary spaces(not @ beginning , end). not link search box on submit exploded + can = or basically

$string = preg_replace('/\s+/', ' ', $string); 

Comments

Popular posts from this blog

javascript - Iterate over array and calculate average values of array-parts -

php - How can I edit my code to echo the data of child's element where my search term was found in, in XMLReader? -

iphone - Pop a UIViewController containing a UITabBarController off of a UINavigationController -