note 114614 added to function.array-slice
| From: | info | Date: | Wed, 12 Mar 2014 13:04:56 +0000 |
| Subject: | note 114614 added to function.array-slice | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-198871@lists.php.net to get a copy of this message | ||
Here is analog to this function. Hope that it helps
function filter_array($input_array, $filter_from, $filter_to)
{
$output_array = array();
foreach ($input_array as $key => $value)
{
if($key>=$filter_from && $key<=$filter_to)
{
$output_array[] = $value;
}
elseif ($key>$filter_to)
{
//if the key is larger than what we want to filter
//it is useless to continue looping
break;
}
else
{
//if the key is smaller than what we expect
continue;
}
}
return $output_array;
}
// you can add more security defenses for the variables - e.g. if it is string or something like
that
----
Server IP: 89.190.194.18
Probable Submitter: 78.90.87.67
----
Manual Page -- http://php.net/manual/en/function.array-slice.php
Edit -- https://master.php.net/note/edit/114614
Del: integrated -- https://master.php.net/note/delete/114614/integrated
Del: useless -- https://master.php.net/note/delete/114614/useless
Del: bad code -- https://master.php.net/note/delete/114614/bad+code
Del: spam -- https://master.php.net/note/delete/114614/spam
Del: non-english -- https://master.php.net/note/delete/114614/non-english
Del: in docs -- https://master.php.net/note/delete/114614/in+docs
Del: other reasons-- https://master.php.net/note/delete/114614
Reject -- https://master.php.net/note/reject/114614
Search -- https://master.php.net/manage/user-notes.php