note 76543 added to function.str-word-count

From: Date: Thu, 19 Jul 2007 20:16:47 +0000
Subject: note 76543 added to function.str-word-count
Groups: php.notes 
Request: Send a blank email to php-notes+get-128745@lists.php.net to get a copy of this message
A cute little function for truncating text to a given word limit: <?php function limit_text($text, $limit) { if (strlen($text) > $limit) { $words = str_word_count($text, 2); $pos = array_keys($words); $text = substr($text, 0, $pos[$limit]) . '...'; } return $text; } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 75.42.162.49 ---- Manual Page -- http://www.php.net/manual/en/function.str-word-count.php Edit -- https://master.php.net/note/edit/76543 Del: integrated -- https://master.php.net/note/delete/76543/integrated Del: useless -- https://master.php.net/note/delete/76543/useless Del: bad code -- https://master.php.net/note/delete/76543/bad+code Del: spam -- https://master.php.net/note/delete/76543/spam Del: non-english -- https://master.php.net/note/delete/76543/non-english Del: in docs -- https://master.php.net/note/delete/76543/in+docs Del: other reasons-- https://master.php.net/note/delete/76543 Reject -- https://master.php.net/note/reject/76543 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#128745) next »