Re: space in strings
| From: | CC Zona | Date: | Tue, 14 Aug 2001 04:22:04 +0000 |
| Subject: | Re: space in strings | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-62560@lists.php.net to get a copy of this message | ||
In article <001301c12476$3420f300$82602c3f@2pqjp01>,
dabigdemp@hotmail.com (Jack Dempsey) wrote:
> > that removes trailing space - but is there one that removes ALL spaces
> > from a string? Like:
> >
> > $string = "this is a string";
> > rmspc($string);
> > // $string is now "thisisastring"
> $string = str_replace(' ','',$string);
Or if you want to strip all typres of whitespace (space chars, tabs,
newlines, carriage returns)...
$string = preg_replace('|\s|','',$string);
--
CC