note 88518 deleted from function.wordwrap by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 18:26:58 +0000 |
| Subject: | note 88518 deleted from function.wordwrap by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-155116@lists.php.net to get a copy of this message | ||
Note Submitter: phuein a..t! g--- mail co . . m lol blah
----
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.