|
array_sliceExtract a slice of the array Description
array array_slice(
array $array ,int $offset ,intnull $length = null ,bool $preserve_keys = false )
array_slice returns the sequence of elements
from the array Parameters
Return ValuesReturns the slice. If the offset is larger than the size of the array, an empty array is returned. Examples
Example #1 array_slice examples
The above example will output: Array ( [0] => c [1] => d ) Array ( [2] => c [3] => d )
Example #2 array_slice and one-based array
The above example will output: Array ( [0] => b [1] => c )
Example #3 array_slice and array with mixed keys
The above example will output: Array ( [a] => apple [b] => banana [0] => pear ) Array ( [a] => apple [b] => banana [42] => pear ) See Also
|