note 88623 deleted from function.wordwrap by danbrown
| From: | danbrown@php.net | Date: | Sun, 01 Feb 2009 16:53:33 +0000 |
| Subject: | note 88623 deleted from function.wordwrap by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-150063@lists.php.net to get a copy of this message | ||
Note Submitter: ace
----
function htmlwordwrap(&$text, $width = 10, $break = '<br />', $space = '
') {
$i = 0; $count = 0; $tag = false;
while ($i < strlen($text)) {
$char = substr($text, $i, 1);
if ($char == '<') {
$tag = true;
$count = 0;
} else if ($char == '>') {
$tag = false;
$count = 0;
}
else if ($char == $space) $count = 0;
else if (!$tag) $count++;
if ($count > $width) {
$text = substr($text, 0, $i) . $break . substr($text, $i);
$count = 0;
$i += strlen($break) - 1;
}
$i++;
}
return $text;
}