asmith Posted August 18, 2008 Share Posted August 18, 2008 Hey Is there any php built-in function to make all spaces in the entire paragraph into one ? for example : $a = "This text will become to this "; the output become this : $a = "This text will become to this "; Quote Link to comment https://forums.phpfreaks.com/topic/120178-solved-making-all-spaces-into-one/ Share on other sites More sharing options...
JonnoTheDev Posted August 18, 2008 Share Posted August 18, 2008 $string = "This text will become to this "; $string = preg_replace('/ {2,}/', ' ', $string); print $string; Quote Link to comment https://forums.phpfreaks.com/topic/120178-solved-making-all-spaces-into-one/#findComment-619102 Share on other sites More sharing options...
asmith Posted August 18, 2008 Author Share Posted August 18, 2008 Thanks man I had completely forgotten preg_replace Quote Link to comment https://forums.phpfreaks.com/topic/120178-solved-making-all-spaces-into-one/#findComment-619103 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.