Re: Re: split on whitespace, preserving whitespace...

From: Date: Fri, 20 Jul 2001 14:05:48 +0000
Subject: Re: Re: split on whitespace, preserving whitespace...
Groups: php.general 
Request: Send a blank email to php-general+get-58901@lists.php.net to get a copy of this message
On Fri, 20 Jul 2001 09:32:00 -0400 "Jack Dempsey" wrote: > > $text = "This contans white space ."; > $matches = preg_split("/(\s+)/",$text,-1, PREG_SPLIT_DELIM_CAPTURE); > echo implode('',$matches); Nope that doesn't do it. here's the test: echo "<pre>[$text]<br>[". implode('',$matches)."]</pre>"; here's the output: [This contans white space .] [Thiscontanswhitespace.] If it were working the two lines should be identical. Northern.CA ===-- http://www.northern.ca Canada's Search Engine > -----Original Message----- > mmm... yeah... That's what I had before > (acutally I was using the alias split)... > it does NOT however preserve the areas > of white space. > > Instead the target of: > > > $wordsarr = ('This',' ','contans',' > > > ','white',' ','space',' > ','.') > > You get: > > > $wordsarr = > > > ('This','','contans','','white','space','','.') > > which has totally destroyed the whitespace I'm trying to > keep intacted.

« previous php.general (#58901) next »