note 54276 deleted from function.wordwrap by betz
| From: | betz@php.net | Date: | Wed, 29 Jun 2005 20:37:00 +0000 |
| Subject: | note 54276 deleted from function.wordwrap by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-91158@lists.php.net to get a copy of this message | ||
Note Submitter:
Reason: non-english
----
Cuts texts to a specified length. If possible not within a word.
function beschreibung_kuerzen ($in, $cut=90, $break=10) {
//$cut ist die soll länge
//$break ist der maximale "Überhang" zu $cut nachdem geschnitten wird auch wenn kein
Space gefudnen wurde
//dh der string ohne "..." ist maximal $break+$cut Zeichen lang.
$in=html_entity_decode(trim($in), ENT_QUOTES);
if (strlen($in)>$cut) {
$i=0;
while (substr($in,($cut+$i),1)!=" " && substr($in,($cut-$i),1)!=" "
&& $i<$break) $i++;
if (substr($in,($i+$cut),1)==" ") $in=substr($in,0,($i+$cut))."...";
elseif (substr($in,($cut-$i),1)==" ") $in=substr($in,0,($cut-$i))."...";
else $in=substr($in, 0, $cut)."...";
}
return htmlentities($in);
}