note 88518 modified in function.wordwrap by danbrown
| From: | danbrown@php.net | Date: | Tue, 27 Jan 2009 19:44:10 +0000 |
| Subject: | note 88518 modified in function.wordwrap by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-149860@lists.php.net to get a copy of this message | ||
znupiDONTWANTSPAM69 at gmail dot comBLAH
24-Feb-2008 06:05
gave a nice good function that I converted into utf-8 for my needs :+D
Thank you dude!
Here's my version of it:
<?php
function layout_wrap($str, $i)
{
$j = $i;
$length = mb_strlen($str, 'UTF-8');
while ($i < $length)
{
if (mb_strpos($str, ' ', $i-$j+1, 'UTF-8') > $i+$j ||
mb_strpos($str, ' ', $i-$j+1, 'UTF-8') === false)
{
$str = mb_substr($str, 0, $i, 'UTF-8') . ' ' . mb_substr($str, $i,
$length,'UTF-8');
}
$i += $j;
}
return $str;
}
?>
I hope I didn't screw things up. Seems to work for me. I'm rather a noob, so do mind.
--was--
znupiDONTWANTSPAM69 at gmail dot comBLAH
24-Feb-2008 06:05
gave a nice good function that I converted into utf-8 for my needs :+D
Thank you dude!
Here's my version of it:
function layout_wrap($str, $i)
{
$j = $i;
$length = mb_strlen($str, 'UTF-8');
while ($i < $length)
{
if (mb_strpos($str, ' ', $i-$j+1, 'UTF-8') > $i+$j ||
mb_strpos($str, ' ', $i-$j+1, 'UTF-8') === false)
{
$str = mb_substr($str, 0, $i, 'UTF-8') . ' ' . mb_substr($str, $i,
$length,'UTF-8');
}
$i += $j;
}
return $str;
}
I hope I didn't screw things up. Seems to work for me. I'm rather a noob, so do mind.
http://php.net/manual/en/function.wordwrap.php