note 88450 deleted from function.wordwrap by danbrown

From: Date: Sun, 17 May 2009 18:27:03 +0000
Subject: note 88450 deleted from function.wordwrap by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-155117@lists.php.net to get a copy of this message
Note Submitter: nightfall at example dot com ---- <?php function mb_wrap($string, $length = 75, $break = "\n", $encoding = 'UTF-8') { $para = mb_split($break, $string); $string = ''; while (count($para)) { $list = mb_split(' ', array_shift($para)); $len = 0; while (count($list)) { $line = array_shift($list); $l = mb_strlen($line, $encoding); if ($len + 1 + $l <= $length) { $string .= ($len ? ' ' : '').$line; $len += 1 + $l; } else { $string .= $break.$line; if ($l > $length) { $string .= $break; $len = 0; } else $len = $l; } } if (count($para)) $string .= $break; } return $string; } ?>

« previous php.notes (#155117) next »