note 40588 deleted from function.str-split by nlopess
| From: | nlopess@php.net | Date: | Tue, 09 Mar 2004 14:56:18 +0000 |
| Subject: | note 40588 deleted from function.str-split by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-66499@lists.php.net to get a copy of this message | ||
Note Submitter: Team @ Cerberus Helpdesk dot com
----
Here's what we came up with:
function strSplit($string,$len) {
$len = abs((int)$len);
if(empty($len)) return array($string);
$chunks = array();
$remainder = $string;
while(!empty($remainder)) {
$chunks[] = substr($remainder,0,$len);
$remainder = substr($remainder,$len);
}
return $chunks;
}
Thanks!