note 106827 added to function.str-split
| From: | Paul at osu1 dot php dot net | Date: | Fri, 09 Dec 2011 12:49:41 +0000 |
| Subject: | note 106827 added to function.str-split | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-184996@lists.php.net to get a copy of this message | ||
In addition to ference at super_delete_brose dot co dot uk
(http://php.net/manual/en/function.str-split.php#69331) it would be good to include encoding
detection for the multi-byte split function because the multi-byte functions default to the internal
encoding value.
The multi-byte split function would look something like this:
<?php
function mb_str_split($str, $length = 1) {
if ($length < 1)
return false;
if (!($encoding = mb_detect_encoding($str)))
$encoding = mb_internal_encoding();
for ($result = array(), $i = 0; $i < mb_strlen($str, $encoding); $i += $length)
$result[] = mb_substr($str, $i, $length, $encoding);
return $result;
}
?>
----
Server IP: 91.199.167.223
Probable Submitter: 81.204.53.52
----
Manual Page -- http://www.php.net/manual/en/function.str-split.php
Edit -- https://master.php.net/note/edit/106827
Del: integrated -- https://master.php.net/note/delete/106827/integrated
Del: useless -- https://master.php.net/note/delete/106827/useless
Del: bad code -- https://master.php.net/note/delete/106827/bad+code
Del: spam -- https://master.php.net/note/delete/106827/spam
Del: non-english -- https://master.php.net/note/delete/106827/non-english
Del: in docs -- https://master.php.net/note/delete/106827/in+docs
Del: other reasons-- https://master.php.net/note/delete/106827
Reject -- https://master.php.net/note/reject/106827
Search -- https://master.php.net/manage/user-notes.php