PHP/Data Structure/array slice
array_slice
<?php
$states = array("Alabama", "Alaska", "Arizona");
$subset = array_slice($states, 4);
print_r($subset);
?>
Extract a slice of the array
<?
$input = array ("a", "b", "c", "d", "e");
$output = array_slice ($input, 2);
$output = array_slice ($input, 2, -1);
$output = array_slice ($input, -2, 1);
$output = array_slice ($input, 0, 3);
?>
Extracting a Portion of an Array: array array_slice(array $array, int $offset[, int $length[, bool $preserve]] )
<?php
$languages = array( "French", "German", "Russian", "Chinese");
printf("<pre>Original array:\n%s</pre>\n", var_export($languages, TRUE));
$slice1 = array_slice($languages, 2, count($languages) - 2);
printf("<pre>Slice 1:\n%s</pre>\n", var_export($slice1, TRUE));
$slice2 = array_slice($languages, 2, count($languages) - 2, TRUE);
printf("<pre>Slice 2:\n%s</pre>\n", var_export($slice2, TRUE));
?>