array array_slice ( array $array , int $offset [, int $length = NULL [, bool $preserve_keys = false ]] )
Extract a slice of the array
array_slice() returns the sequence of elements from the array array as specified by the offset and length parameters.
<?php
$input = array("a", "b", "c", "d", "e");
$output = array_slice($input, 2); // returns "c", "d", and "e"
$output = array_slice($input, -2, 1); // returns "d"
$output = array_slice($input, 0, 3); // returns "a", "b", and "c"
// note the differences in the array keys
print_r(array_slice($input, 2, -1));
print_r(array_slice($input, 2, -1, true));
?>
5.0.2 The optional preserve_keys parameter was added.
0 Comment:
Post a Comment