Extract a slice of the array : array_slice « Data Structure « PHP






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); 
?>
  
  








Related examples in the same category

1.Extracting a Portion of an Array: array array_slice(array $array, int $offset[, int $length[, bool $preserve]] )
2.array_slice