note 18074 deleted from function.array-chunk by alindeman
| From: | alindeman@php.net | Date: | Sat, 03 May 2003 21:05:53 +0000 |
| Subject: | note 18074 deleted from function.array-chunk by alindeman | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-47461@lists.php.net to get a copy of this message | ||
Here is the function in PHP since it is only available in the CVS...
-Jeff Nappi
brage@brageproductions<DOT HERE>com
function array_chunk ($a, $s, $p=false) {
$r = Array();
$ak = array_keys($a);
$i = 0;
$sc = 0;
for ($x=0;$x<count($ak);$x++) {
if ($i == $s){$i = 0;$sc++;}
$k = ($p) ? $ak[$x] : $i;
$r[$sc][$k] = $a[$ak[$x]];
$i++;
}
return $r;
}