note 101050 deleted from function.chunk-split by thiago

From: Date: Tue, 23 Nov 2010 13:02:39 +0000
Subject: note 101050 deleted from function.chunk-split by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-174283@lists.php.net to get a copy of this message
Note Submitter: Anonymous ---- <?php function mbStringToArray ($str) { if (empty($str)) return false; $len = mb_strlen($str); $array = array(); for ($i = 0; $i < $len; $i++) { $array[] = mb_substr($str, $i, 1); } return $array; } function mb_chunk_split($str, $len, $glue) { if (empty($str)) return false; $array = mbStringToArray ($str); $n = -1; $new = ''; foreach ($array as $char) { $n++; if ($n < $len) $new .= $char; elseif ($n == $len) { $new .= $glue . $char; $n = 0; } } return $new; }

« previous php.notes (#174283) next »