note 80195 deleted from function.str-split by crell
| From: | crell@php.net | Date: | Wed, 29 Jun 2022 18:34:06 +0000 |
| Subject: | note 80195 deleted from function.str-split by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218694@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
Version of str_split by rlpvandenberg at hotmail dot com is god-damn inefficient and when $i+$j >
strlen($text) [last part of string] throws a lot of notice errors. This should work better:
if(! function_exists('str_split'))
{
function str_split($text, $split = 1)
{
$array = array();
for ($i = 0; $i < strlen($text);)
{
$array[] = substr($text, $i, $split);
$i += $split;
}
return $array;
}
}