note 95685 added to function.str-word-count
| From: | PHPimpin at osu1 dot php dot net | Date: | Fri, 15 Jan 2010 20:22:03 +0000 |
| Subject: | note 95685 added to function.str-word-count | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-165011@lists.php.net to get a copy of this message | ||
I fixed pdziok's version.
function WordLimiter($text,$limit=20){
$explode = str_word_count($text,1);
$string = '';
$dots = '...';
if(count($explode) <= $limit){
$dots = '';
foreach(array_keys($explode) as $key){
$string .= $explode[$key]." ";
}
} else {
for($i=0;$i<=$limit;$i++){
$string .= $explode[$i]." ";
}
}
if ($dots) {
$string = substr($string, 0, strlen($string));
}
return $string.$dots;
}
----
Server IP: 192.41.40.227
Probable Submitter: 68.75.18.165
----
Manual Page -- http://www.php.net/manual/en/function.str-word-count.php
Edit -- https://master.php.net/note/edit/95685
Del: integrated -- https://master.php.net/note/delete/95685/integrated
Del: useless -- https://master.php.net/note/delete/95685/useless
Del: bad code -- https://master.php.net/note/delete/95685/bad+code
Del: spam -- https://master.php.net/note/delete/95685/spam
Del: non-english -- https://master.php.net/note/delete/95685/non-english
Del: in docs -- https://master.php.net/note/delete/95685/in+docs
Del: other reasons-- https://master.php.net/note/delete/95685
Reject -- https://master.php.net/note/reject/95685
Search -- https://master.php.net/manage/user-notes.php