Home > Article > Backend Development > PHP array splitting and array joining
Then, use the lower negative length:
Splice array array_splice() Thearray_splice() function will delete all elements starting from offset and ending at offset+length in the array, and return the deleted elements in the form of an array. Its form is: array array_splice ( array array , int offset[,length[,array replacement]]) When offset is a positive value, the join will start at the offset position from the beginning of the array. When offset is a negative value, the join will start at the offset position from the end of the array. If the optional length parameter is omitted, all elements starting at offset position and ending at the end of the array will be removed. If length is given and is positive, the join ends at offset + leng th from the beginning of the array. Conversely, if length is given and is negative, the union will end count(input_array)-length from the beginning of the array. Example:
The optional parameter replacement can be used to specify the array to replace the target part. Example:
|