Name
array_slice
Synopsis
array array_slice(arrayarray
, intoffset
[, intlength
][, boolkeepkeys
])
Returns an array containing a set of elements pulled from the
given array. If offset
is a positive
number, elements starting from that index onward are used; if
offset
is a negative number, elements
starting that many elements from the end of the array are used. If the
third argument is provided and is a positive number, that many
elements are returned; if negative, the sequence stops that many
elements from the end of the array. If the third argument is omitted,
the sequence returned contains all elements from the offset to the end
of the array. If keepkeys
, the
fourth argument, is true
, then the
order of numeric keys will be preserved; otherwise they will be
renumbered and resorted.
Get Programming PHP, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.