note 92020 added to function.str-word-count

From: Date: Sun, 05 Jul 2009 19:08:41 +0000
Subject: note 92020 added to function.str-word-count
Groups: php.notes 
Request: Send a blank email to php-notes+get-157944@lists.php.net to get a copy of this message
I like your function eanimator but it got a little mistake - before the dots it putted another space. This is a version with "bug" repaired: <?php function WordLimiter($text,$limit=20){ $explode = explode(' ',$text); $string = ''; $dots = '...'; if(count($explode) <= $limit){ $dots = ''; } for($i=0;$i<$limit;$i++){ $string .= $explode[$i]." "; } if ($dots) { $string = substr($string, 0, strlen($string)); } return $string.$dots; } ?> ---- Server IP: 82.177.164.100 Probable Submitter: 90.141.98.64 ---- Manual Page -- http://www.php.net/manual/en/function.str-word-count.php Edit -- https://master.php.net/note/edit/92020 Del: integrated -- https://master.php.net/note/delete/92020/integrated Del: useless -- https://master.php.net/note/delete/92020/useless Del: bad code -- https://master.php.net/note/delete/92020/bad+code Del: spam -- https://master.php.net/note/delete/92020/spam Del: non-english -- https://master.php.net/note/delete/92020/non-english Del: in docs -- https://master.php.net/note/delete/92020/in+docs Del: other reasons-- https://master.php.net/note/delete/92020 Reject -- https://master.php.net/note/reject/92020 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#157944) next »