You are here: Re: preg_split « All PHP « IT news, forums, messages
Re: preg_split

Posted by www.douglassdavis.com on 10/03/05 16:17

Andrew @ Rockface wrote:
> www.douglassdavis.com wrote:
> > lets say I have a line of text with multiple spaces between each word..
> > I am not sure how many spaces. I would like to take the line of text,
> > and change it to put only one space between the words.
>
> If you just want to replace multiple blanks between words try:
> $string = preg_replace("/\s+/", " ", $string);
>

much better... thanks.

> > So, my idea was to split it on the spaces, then implode it with one
> > space between each word.
> >
> > But, this doesn't work:
> >
> > preg_split("/\\s*/","test test test test")
>
> Replace * with +

I hadn't thought of that... makes sense.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация