note 59290 deleted from function.str-split by aidan
| From: | aidan@php.net | Date: | Sat, 04 Feb 2006 07:13:40 +0000 |
| Subject: | note 59290 deleted from function.str-split by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-102958@lists.php.net to get a copy of this message | ||
Note Submitter:
----
Another piece of code to replicate str_split() behaviour in PHP 4. No crazy explodes, unpacking or
regular expressions.
<?php
if (!function_exists('str_split')){
function str_split($string, $split_length=1){
if ($split_length < 1){
return false;
}
for ($pos=0, $chunks = array(); $pos < strlen($string); $pos+=$split_length){
$chunks[] = substr($string, $pos, $split_length);
}
return $chunks;
}
}
?>