Re: strip spaces from inside string

From: Date: Tue, 26 Mar 2002 20:13:37 +0000
Subject: Re: strip spaces from inside string
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-90264@lists.php.net to get a copy of this message
> Say I have a string "xyz abc def" and I want to remove all of the spaces > withing the string to create a new one. What's the best way? <? $string = "xyz abc def"; $stringWithOutSpaces = implode( "", explode( " ", $string )); ?> Or you can use eregi_replace(), but I don't know what the regex would be. I *think* you can do: <? $string = "xyz abc def"; $stringWithOutSpaces = eregi_replace( " ", "", $string ); ?> Chris

« previous php.general (#90264) next »