note 92616 deleted from function.wordwrap by danbrown

From: Date: Wed, 05 May 2010 14:18:00 +0000
Subject: note 92616 deleted from function.wordwrap by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-168970@lists.php.net to get a copy of this message
Note Submitter: VladX (vvladxx at gmail dot com) ---- My variant of multibyte wordwrap() <?php function utf8_wordwrap($str, $width = 75, $break = "\n") // wordwrap() with utf-8 support { $str = preg_split('#[\s\n\r]+#', $str); $len = 0; foreach ($str as $val) { $val .= ' '; $tmp = mb_strlen($val, 'utf-8'); $len += $tmp; if ($len >= $width) { $return .= $break . $val; $len = $tmp; } else $return .= $val; } return $return; } ?>

« previous php.notes (#168970) next »