array_splice

PHP 4, PHP 5, PHP 7, PHP 8
array_splice - Remove a portion of the array and replace it with something else

Example #1 array_splice examples

Result: array(2) { [0]=> string(3) "red" [1]=> string(5) "green" } array(2) { [0]=> string(3) "red" [1]=> string(6) "yellow" } array(2) { [0]=> string(3) "red" [1]=> string(6) "orange" } array(5) { [0]=> string(3) "red" [1]=> string(5) "green" [2]=> string(4) "blue" [3]=> string(5) "black" [4]=> string(6) "maroon" }
PHP Version:

Example #2 Equivalent statements to various array_splice examples

PHP Version:


Example #3 of array_splice

PHP Version: