note 107711 added to function.chunk-split
| From: | qeremy | Date: | Tue, 28 Feb 2012 15:35:28 +0000 |
| Subject: | note 107711 added to function.chunk-split | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-186412@lists.php.net to get a copy of this message | ||
An alternative for unicode strings;
<?php
function chunk_split_unicode($str, $l = 76, $e = "\r\n") {
$tmp = array_chunk(
preg_split("//u", $str, -1, PREG_SPLIT_NO_EMPTY), $l);
$str = "";
foreach ($tmp as $t) {
$str .= join("", $t) . $e;
}
return $str;
}
$str = "Yarım kilo çay, yarım kilo Åeker";
echo chunk_split($str, 4) ."\n";
echo chunk_split_unicode($str, 4);
?>
Yar�
�m k
ilo
çay
, ya
rım
kil
o Å
eker
Yarı
m ki
lo ç
ay,
yarı
m ki
lo Å
eker
----
Server IP: 69.147.83.197
Probable Submitter: 194.27.149.90
----
Manual Page -- http://www.php.net/manual/en/function.chunk-split.php
Edit -- https://master.php.net/note/edit/107711
Del: integrated -- https://master.php.net/note/delete/107711/integrated
Del: useless -- https://master.php.net/note/delete/107711/useless
Del: bad code -- https://master.php.net/note/delete/107711/bad+code
Del: spam -- https://master.php.net/note/delete/107711/spam
Del: non-english -- https://master.php.net/note/delete/107711/non-english
Del: in docs -- https://master.php.net/note/delete/107711/in+docs
Del: other reasons-- https://master.php.net/note/delete/107711
Reject -- https://master.php.net/note/reject/107711
Search -- https://master.php.net/manage/user-notes.php