note 98376 deleted from function.wordwrap by peehaa

From: Date: Thu, 09 Mar 2017 09:11:35 +0000
Subject: note 98376 deleted from function.wordwrap by peehaa
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-208877@lists.php.net to get a copy of this message
Note Submitter: Ivan Lisnik ---- here is my example of UTF-8 wordwrap <?php function wordwrap($str, $width, $break) { $return = ''; $br_width = mb_strlen($break, 'UTF-8'); for($i = 0, $count = 0; $i < mb_strlen($str, 'UTF-8'); $i++, $count++) { if (mb_substr($str, $i, $br_width, 'UTF-8') == $break) { $count = 0; $return .= mb_substr($str, $i, $br_width, 'UTF-8'); $i += $br_width - 1; } if ($count > $width) { $return .= $break; $count = 0; } $return .= mb_substr($str, $i, 1, 'UTF-8'); } return $return; } ?>

« previous php.notes (#208877) next »