note 102631 deleted from function.array-slice by danbrown
| From: | danbrown@php.net | Date: | Fri, 25 Feb 2011 14:33:20 +0000 |
| Subject: | note 102631 deleted from function.array-slice by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-177328@lists.php.net to get a copy of this message | ||
Note Submitter: rehnahmed [at] gmail [dot] com
----
Best function to slice an array in two parts.
function chopArray($result, $start, $end)
{
$i = 1;
$outcome = array();
foreach($result as $res)
{
if($i >= $start && $i <= $end )
$outcome = $res;
$i++;
if($i > $end)
break;
}
return $outcome;
}
Hope it will help you.