scarhand Posted April 6, 2009 Share Posted April 6, 2009 ive got a string: 55 | 30 i want to use preg_replace to make it look nicer, i.e: 55 | 30 You can see there is a line break there too I want to get rid of. edit: can a mod move this to regex? my bad. Link to comment https://forums.phpfreaks.com/topic/152863-solved-replace-2-or-more-spaces-with-1-inside-string/ Share on other sites More sharing options...
thepip3r Posted April 6, 2009 Share Posted April 6, 2009 explode on pipe (|), trim() all whitespace, implode with the desired whitespace -- although, your data resulting like that points to something else not trimming white-space initially - might want to start there. =P Link to comment https://forums.phpfreaks.com/topic/152863-solved-replace-2-or-more-spaces-with-1-inside-string/#findComment-802768 Share on other sites More sharing options...
scarhand Posted April 6, 2009 Author Share Posted April 6, 2009 wow didnt think of that, thanks! Link to comment https://forums.phpfreaks.com/topic/152863-solved-replace-2-or-more-spaces-with-1-inside-string/#findComment-802771 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.