note 98699 deleted from function.wordwrap by danbrown
| From: | danbrown@php.net | Date: | Thu, 01 Jul 2010 13:04:53 +0000 |
| Subject: | note 98699 deleted from function.wordwrap by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-170622@lists.php.net to get a copy of this message | ||
Note Submitter: vituko at gmail dot com
----
Well, last try, I hope.
Now I realized that it didn't worked for short strings :
function mb_wordwrap ($cadea, $lonx=75, $sep="\n", $cortar_palabra=false) {
if (!$cortar_palabra)
return substr (preg_replace
('#(([\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){1,'.$lonx.'})(?: |$)+#',
'\1'.$sep, $cadea), 0, -mb_strlen ($sep)) ;
else
return substr (preg_replace
('#(?:((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){1,'.$lonx.'})(?:
|$)+|((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){'.$lonx.'}))#', '\1\2'.$sep,
$cadea), 0, -mb_strlen ($sep)) ;
}