climbjm Posted August 23, 2006 Share Posted August 23, 2006 I want to take any string of two or more spaces and replace it with one space.[code]$string = " ";$string = ereg_replace("\s\s*"," ",$string);[/code]you get the idea...I have a valid reason for needing this, but it is too long to explain. Quote Link to comment Share on other sites More sharing options...
climbjm Posted August 23, 2006 Author Share Posted August 23, 2006 I found what I was looking for...$string = preg_replace("/(\s){2,}/i"," ",$string); // gets rid of mutliple spaces and replaces it with one in the middle of a string. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.