note 38773 deleted from function.array-chunk by nlopess

From: Date: Wed, 07 Jan 2004 14:32:34 +0000
Subject: note 38773 deleted from function.array-chunk by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-63078@lists.php.net to get a copy of this message
Note Submitter: jfardello@sion.com ---- 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; } }

« previous php.notes (#63078) next »