dennismonsewicz Posted July 17, 2008 Share Posted July 17, 2008 Is there anyway to trim white space from a string but at the same time replace that white space with something? Link to comment https://forums.phpfreaks.com/topic/115235-trimming-and-replacing-at-the-same-time/ Share on other sites More sharing options...
ninedoors Posted July 17, 2008 Share Posted July 17, 2008 What do you want to do? Trim the whitespace form the end and beginning of the string and then replace the "left over" whitespace with whatever, say _? If that is the case I don't think there is a function for that but you can just do somethng like this <?php $string = "yourstring"; $newstring = str_replace(" ", "_", trim($string)); ?> Not sure if that is what you are looking for. Nick Link to comment https://forums.phpfreaks.com/topic/115235-trimming-and-replacing-at-the-same-time/#findComment-592464 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.