You are here: Re: [PHP] [DONE] Substr by words « PHP « IT news, forums, messages
Re: [PHP] [DONE] Substr by words

Posted by "Richard Lynch" on 10/29/05 22:41

On Sat, October 29, 2005 10:51 am, Minuk Choi wrote:
> function trim_text($text, $count)
> {
> $text = str_replace(" ", " ", $text);
> /*
> * This is redundant; you are replacing all " " in $text with " "
> * maybe you meant
> * $text = trim($text); ?
> */

It was probably replacing *TWO* spaces with one.

If so, it should really be in a while loop, because there could be 3
or more spaces in a row, and if the goal is only single-spaced
words...

//Replace 2 spaces with 1 until all words are single-spaced
while (strstr($text, ' ')) $text = str_replace(' ', ' ', $text);

PS

My post was doing 50 LETTERS, not 50 words.

So change 50 to 250 and call it done. :-)

Unless the word-count is really that critical...

--
Like Music?
http://l-i-e.com/artists.htm

 

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

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