strip whitespace?
Moderator: General Moderators
- Pyrite
- Forum Regular
- Posts: 769
- Joined: Tue Sep 23, 2003 11:07 pm
- Location: The Republic of Texas
- Contact:
strip whitespace?
Ok, I know about trim(), ltrim() and rtrim(). But is there a way to just strip ALL whitespace from a string?
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
preg_replace(), str_replace()
take your pick, I would probably use str_replace since this a real simple and regex would be overkill
something along the lines of
take your pick, I would probably use str_replace since this a real simple and regex would be overkill
something along the lines of
Code: Select all
$str = str_replace(" ","",$str);- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
well.. since you say whitespace..
Code: Select all
$str = preg_replace('#\s+#s', '', $str);