note 88437 added to function.array-chunk

From: Date: Fri, 23 Jan 2009 21:59:13 +0000
Subject: note 88437 added to function.array-chunk
Groups: php.notes 
Request: Send a blank email to php-notes+get-149718@lists.php.net to get a copy of this message
Unfortunately, this function only accepts real arrays, not iterable objects... For that, you need this function: <?php function break_array($array, $page_size) { $arrays = array(); $i = 0; foreach ($array as $index => $item) { if ($i++ % $page_size == 0) { $arrays[] = array(); $current = & $arrays[count($arrays)-1]; } $current[] = $item; } return $arrays; } ?> ---- Server IP: 208.69.120.35 Probable Submitter: 64.57.178.15 ---- Manual Page -- http://www.php.net/manual/en/function.array-chunk.php Edit -- https://master.php.net/note/edit/88437 Del: integrated -- https://master.php.net/note/delete/88437/integrated Del: useless -- https://master.php.net/note/delete/88437/useless Del: bad code -- https://master.php.net/note/delete/88437/bad+code Del: spam -- https://master.php.net/note/delete/88437/spam Del: non-english -- https://master.php.net/note/delete/88437/non-english Del: in docs -- https://master.php.net/note/delete/88437/in+docs Del: other reasons-- https://master.php.net/note/delete/88437 Reject -- https://master.php.net/note/reject/88437 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#149718) next »