note 80021 added to function.str-word-count
| From: | security_man at osu1 dot php dot net | Date: | Mon, 24 Dec 2007 21:13:13 +0000 |
| Subject: | note 80021 added to function.str-word-count | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-133983@lists.php.net to get a copy of this message | ||
there was a glitch in the code cathy put a post or two ago... should be:
function limit_text($text, $limit) {
$text = strip_tags($text);
$words = str_word_count($text, 2);
$pos = array_keys($words);
if (count($words) > $limit) {
$text = substr($text, 0, $pos[$limit]) . ' ...';
}
return $text;
}
I also added the strip tags in case there is html in there to gum up the works
----
Server IP: 208.69.120.35
Probable Submitter: 38.96.240.193
----
Manual Page -- http://www.php.net/manual/en/function.str-word-count.php
Edit -- https://master.php.net/note/edit/80021
Del: integrated -- https://master.php.net/note/delete/80021/integrated
Del: useless -- https://master.php.net/note/delete/80021/useless
Del: bad code -- https://master.php.net/note/delete/80021/bad+code
Del: spam -- https://master.php.net/note/delete/80021/spam
Del: non-english -- https://master.php.net/note/delete/80021/non-english
Del: in docs -- https://master.php.net/note/delete/80021/in+docs
Del: other reasons-- https://master.php.net/note/delete/80021
Reject -- https://master.php.net/note/reject/80021
Search -- https://master.php.net/manage/user-notes.php