note 100496 added to function.array-slice
| From: | joel dot a dot villarreal at gmail dot com | Date: | Tue, 19 Oct 2010 22:41:54 +0000 |
| Subject: | note 100496 added to function.array-slice | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-173289@lists.php.net to get a copy of this message | ||
An implementation of array_slice that do not resets the cursor.
function get_from_array($arr, $start, $length)
{
$sliced = array();
foreach ($arr as $k => $v)
{
if ($start <= $k && $k <= $start + $length - 1)
{
$sliced[] = $v;
if (count($sliced) == $length) break;
}
}
return $sliced;
}
Cheers,
Joel A. Villarreal Bertoldi
CordobaSitios.com | Web Solutions
JoelAlejandro.com | Multidesign Studio
----
Server IP: 201.216.232.3
Probable Submitter: 190.246.203.69
----
Manual Page -- http://www.php.net/manual/en/function.array-slice.php
Edit -- https://master.php.net/note/edit/100496
Del: integrated -- https://master.php.net/note/delete/100496/integrated
Del: useless -- https://master.php.net/note/delete/100496/useless
Del: bad code -- https://master.php.net/note/delete/100496/bad+code
Del: spam -- https://master.php.net/note/delete/100496/spam
Del: non-english -- https://master.php.net/note/delete/100496/non-english
Del: in docs -- https://master.php.net/note/delete/100496/in+docs
Del: other reasons-- https://master.php.net/note/delete/100496
Reject -- https://master.php.net/note/reject/100496
Search -- https://master.php.net/manage/user-notes.php