Skip to content
Chung Leong edited this page Jan 10, 2022 · 3 revisions

array_splice — Remove a portion of the array and replace it with something else

array array_splice ( array &$input , int32 $offset [, int32 $length = 0 [, array $replacement ]] )

array_splice() removes the elements designated by offset and length from input, and replaces them with the elements of replacement, if supplied.

Parameters

input - The input array.

offset - The start offset of the portion to be removed.

length - If length is omitted, removes everything from offset to the end of the array. If length is specified, then that many elements will be removed.

replacement - If replacement array is specified, then the removed elements are replaced with elements from this array.

If offset and length are such that nothing is removed, then the elements from the replacement array are inserted in the place specified by offset.

Return Values

An array consisting of the extracted elements.

Version

1.0 and above. Prior to version 2.0, neither offset or length can be negative.

Clone this wiki locally