RE: [PHP] Removing WhiteSpace

From: Date: Sun, 10 Sep 2000 13:25:12 +0000
Subject: RE: [PHP] Removing WhiteSpace
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-16054@lists.php.net to get a copy of this message
> Ok, did you look at ereg or preg or at all try to solve the problem > before asking thousands of people? I think not. As per the comments below, I did actually. I almost got close as I ended up with the " +"," " bit but I was using preg_replace which I couldn't get to work. I even went through all of the regex(7) man page stuff as per the manual. I keep a PDF version of the manual open at all times when working (I spent hours creating all of the bookmarks for all of the sections and functions) > Nevertheless, I will answer, cuz I'm a nice guy. > $string = ereg_replace(" +", " ", $string); And I really do appreciate it as I spent about 4 hours on this before begging for help. BTW: Do you think anyone would be interested in the bookmarked PDF file. It is based upon the manual.A4.en.pdf file. > > > >A bit lazy I guess, but I'm having trouble trying to replace multiple > > > spaces in a string. > > > > > > > >I'm concatenating variables from a form such as > > > >$string=$Salutation.$First_Name.$Initial.$Surname > > > >The string could be "Mr Grant Walters" and I want "Mr Grant Walters". > > > > > > > >I looked at preg_replace but don't really understand it. I keep getting empty strings. > > > > > > Regards GRANT WALTERS Walters & Associates, P O Box 13-043, Johnsonville, Wellington, New Zealand Phone: +64 4 4765175 CellPhone: 025 488265

« previous php.general (#16054) next »