Re: [PHP] Remove Spaces from Middle of String

2006-10-03 Thread Kevin Murphy
Works perfect! Thanks. -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada Community College www.wncc.edu 775-445-3326 On Oct 3, 2006, at 3:30 PM, Robert Cummings wrote: On Tue, 2006-10-03 at 15:17 -0500, Richard Lynch wrote: On Tue, October 3, 2006 1:47 pm, Richard

Re: [PHP] Remove Spaces from Middle of String

2006-10-03 Thread Robert Cummings
On Tue, 2006-10-03 at 15:17 -0500, Richard Lynch wrote: > On Tue, October 3, 2006 1:47 pm, Richard Lynch wrote: > > If you have this, it's better: > > $data = preg_replace("/ /", $data); > > D'oh! > > $data = preg_replace("/ /", " ", $data); Doesn't work on 3+ spaces in a row ;) $data = p

Re: [PHP] Remove Spaces from Middle of String

2006-10-03 Thread Richard Lynch
On Tue, October 3, 2006 1:47 pm, Richard Lynch wrote: > If you have this, it's better: > $data = preg_replace("/ /", $data); D'oh! $data = preg_replace("/ /", " ", $data); Sorry! -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. htt

Re: [PHP] Remove Spaces from Middle of String

2006-10-03 Thread Richard Lynch
If you have this, it's better: $data = preg_replace("/ /", $data); You may want to consider "/\\s+/" if you want newlines to be collapsed in as well. If preg_replace is not in your PHP, so you gotta use str_replace, then strstr is better to find the ' ' because it's probably slightly faster than

Re: [PHP] Remove Spaces from Middle of String

2006-10-03 Thread Alexandru E. Ungur
>>> sender: "Kevin Murphy" date: "Tue, Oct 03, 2006 at 11:08:23AM -0700" << This works, but I was wondering if this was the best way to > accomplish this or not. I'm trying to remove any extra spaces (not > whitespace like carriage returns) from the middle of a string > mainly for times w

[PHP] Remove Spaces from Middle of String

2006-10-03 Thread Kevin Murphy
This works, but I was wondering if this was the best way to accomplish this or not. I'm trying to remove any extra spaces (not whitespace like carriage returns) from the middle of a string mainly for times where people put extra spaces after periods in paragraph. while(preg_ma