note 60520 deleted from function.wordwrap by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 18:32:27 +0000 |
| Subject: | note 60520 deleted from function.wordwrap by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-155135@lists.php.net to get a copy of this message | ||
Note Submitter: matyx666 at yahoo dot com dot ar
----
This function wraps a string with the characters count specified:
static function cortarCaracteres($sText, $iCharsCount, $sCutWith = "...") {
$sTextLength = strlen($sText);
if($sTextLength <= $iCharsCount) {
return $sText;
}
if($sTextLength+strlen($sCutWith) > $iCharsCount) {
return substr($sText, 0, $iCharsCount-strlen($sCutWith)).$sCutWith;
}
$iLeftOverChars = strlen($sCutWith) - ($sTextLength - $iCharsCount);
return substr($sText, 0, $sTextLength-$iLeftOverChars).$sCutWith;
}
Regards!