/ Published in: PHP
Expand |
Embed | Plain Text
function trimText ( $text, $trimNumber ) { // trim the text to trimNumber amount of words $trimmed = NULL; { for ( $wordCounter = 0 ; $wordCounter <= $trimNumber ; $wordCounter++ ){ $trimmed .= $string[$wordCounter]; if ( $wordCounter < $trimNumber ){ $trimmed .= " "; } else { $trimmed .= "..."; } } } else { $trimmed = $text; } return ($trimmed); }
You need to login to post a comment.
