Re: ereg_replace for whitespace?

From: Date: Mon, 21 Aug 2000 23:09:26 +0000
Subject: Re: ereg_replace for whitespace?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-12836@lists.php.net to get a copy of this message
Hi James, This is probably what you want. ereg_replace('\ +', ' ', $$userd[fname]); Side note (to be completely correct, I would wrap your array key in quotes as well. IE. $userd['fname']. It is infact a string key, not an INT). Cheers, -jeremy brand > > Hi all, > > So I need to remove all traces of whitespace from a string except for > single whitespaces... > > Example: > from "this is too much whitespace you see " > to "this is too much whitespace you see " > the latter being the desired string > > I was given > $fname = ereg_replace("\s+", " ", $userd[fname]); > as a suggestion, however it removes all 's'es from the string. > > Can anyone suggest the correct recipe? > > Many thanks. > > -- > James Green jg@linux.com > Programmer jg@bp2bp.com > Programmer, Manager jg@linuxnewbie.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#12836) next »