brown2005 Posted January 21, 2011 Share Posted January 21, 2011 $string = " hel lo "; $string = rtrim($string); $string= ltrim($string); which trims the whitespace from the front and back, but how do i remove the middle space? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/225193-trim-whitespace-in-a-string/ Share on other sites More sharing options...
Valakai Posted January 21, 2011 Share Posted January 21, 2011 str_replace(' ', '', $text); Quote Link to comment https://forums.phpfreaks.com/topic/225193-trim-whitespace-in-a-string/#findComment-1163044 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.