Re: [DONE] Substr by words

From: Date: Sat, 29 Oct 2005 19:41:44 +0000
Subject: Re: [DONE] Substr by words
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-224820@lists.php.net to get a copy of this message
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

« previous php.general (#224820) next »