note 106405 deleted from function.chunk-split by danbrown
| From: | danbrown@php.net | Date: | Tue, 15 Nov 2011 16:51:50 +0000 |
| Subject: | note 106405 deleted from function.chunk-split by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-184510@lists.php.net to get a copy of this message | ||
Note Submitter: txgruppi at gmail dot com
----
My version of chunk_split for utf-8 string
<?php
function utf8_chunk_split($text, $length, $string_end) {
$text = iconv('utf-8', 'iso-8859-1', $text);
$text = str_split($text);
$new_text = '';
$c = 0;
foreach ($text as $char) {
if ($c >= $length) {
$new_text .= $string_end;
$c = 0;
}
$new_text .= $char;
$c++;
}
$new_text = iconv('iso-8859-1', 'UTF-8', $new_text);
return $new_text;
}
?>