note 80021 deleted from function.str-word-count by danbrown

From: Date: Fri, 31 Aug 2012 16:25:58 +0000
Subject: note 80021 deleted from function.str-word-count by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-190365@lists.php.net to get a copy of this message
Note Submitter: security_man ---- 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

« previous php.notes (#190365) next »