note 38773 added to function.array-chunk
| From: | jfardello at sion dot com | Date: | Tue, 06 Jan 2004 20:28:57 +0000 |
| Subject: | note 38773 added to function.array-chunk | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-63017@lists.php.net to get a copy of this message | ||
I think this one is much more prety, (once saw it here)
it woud prevents the redefinition , what its no legal.
if (!function_exists('array_chunk')){
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;
}
}
----
Manual Page -- http://www.php.net/manual/en/function.array-chunk.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+38773
Delete -- http://master.php.net/manage/user-notes.php?action=delete+38773&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+38773&report=yes
Search -- http://master.php.net/manage/user-notes.php