note 88113 modified in function.str-word-count by danbrown
| From: | danbrown@php.net | Date: | Sun, 11 Jan 2009 08:39:30 +0000 |
| Subject: | note 88113 modified in function.str-word-count by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-149053@lists.php.net to get a copy of this message | ||
My quick and rough wordLimiter function.
<?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]." ";
}
return $string.$dots;
}
?>
--was--
My quick and rough wordLimiter function.
function WordLimiter($text,$limit=20){
$explode = explode(' ',$text);
$string = '';
$dots = '...';
if(count($explode) <= $limit){
$dots = '';
}
for($i=0;$i<$limit;$i++){
$string .= $explode[$i]." ";
}
return $string.$dots;
}
http://php.net/manual/en/function.str-word-count.php