note 53756 deleted from function.str-split by aidan
| From: | aidan@php.net | Date: | Sat, 04 Feb 2006 07:14:43 +0000 |
| Subject: | note 53756 deleted from function.str-split by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-102968@lists.php.net to get a copy of this message | ||
Note Submitter: slgundam at gmail dot com
----
i found this to be the best solution for emulation of the str_split function
if (!function_exists('str_split')){
function str_split($string, $max_length = 1){
for($i = 0, $cur_length = 0, $cur_array = 0, $spl_string = array(0 => '');
isset($string{$i}); $i++, $cur_length++){
if ($cur_length >= $max_length){
$cur_length = 0;
$cur_array++;
$spl_string[$cur_array] = $string{$i};
}
else{
$spl_string[$cur_array] .= $string{$i};
}
}
return($spl_string);
}
}