note 104811 added to function.wordwrap
| From: | info at hsdn dot org | Date: | Fri, 08 Jul 2011 15:41:38 +0000 |
| Subject: | note 104811 added to function.wordwrap | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-181358@lists.php.net to get a copy of this message | ||
Wordwrap with UTF-8 supports, returns as array.
<?php
function mb_wordwrap_array($string, $width)
{
if (($len = mb_strlen($string, 'UTF-8')) <= $width)
{
return array($string);
}
$return = array();
$last_space = FALSE;
$i = 0;
do
{
if (mb_substr($string, $i, 1, 'UTF-8') == ' ')
{
$last_space = $i;
}
if ($i > $width)
{
$last_space = ($last_space == 0) ? $width : $last_space;
$return[] = trim(mb_substr($string, 0, $last_space, 'UTF-8'));
$string = mb_substr($string, $last_space, $len, 'UTF-8');
$len = mb_strlen($string, 'UTF-8');
$i = 0;
}
$i++;
}
while ($i < $len);
$return[] = trim($string);
return $return;
}
?>
----
Server IP: 93.93.89.9
Probable Submitter: 88.147.254.98
----
Manual Page -- http://www.php.net/manual/en/function.wordwrap.php
Edit -- https://master.php.net/note/edit/104811
Del: integrated -- https://master.php.net/note/delete/104811/integrated
Del: useless -- https://master.php.net/note/delete/104811/useless
Del: bad code -- https://master.php.net/note/delete/104811/bad+code
Del: spam -- https://master.php.net/note/delete/104811/spam
Del: non-english -- https://master.php.net/note/delete/104811/non-english
Del: in docs -- https://master.php.net/note/delete/104811/in+docs
Del: other reasons-- https://master.php.net/note/delete/104811
Reject -- https://master.php.net/note/reject/104811
Search -- https://master.php.net/manage/user-notes.php