array_splice()
$arr = array('A', 'B', 'C');
$arr2 = 'abc';
$t = array_splice($arr, 1, 0, $arr2);
print_r($arr);
Console output:
Array ( [0] => 'A' [1] => 'abc' [2] => 'B' [3] => 'C' );
A brief introduction to the array_splice method. The first parameter is the array being operated on, the second parameter is the index value of the operating element, the third parameter is the length, and the fourth parameter is the element to be replaced.
The effect of this method is to delete the consecutive elements with 1 as the starting position and length 0 in $arr, and then fill them with $arr2.
tips:If the length is 0, the effect is equivalent to inserting the specified element at the specified index value.
------------------------------------------------- -----------Gorgeous dividing lineoo00o0ooo0oo. . . --------------------------______________________________
The array_splice above is just pig’s feet,
array_push
array_push -- Push one or more cells to the end of the array (push)
array_push() treats array as a stack and pushes the passed variables into the end of array. The length of array will be increased according to the number of variables pushed onto the stack. The same effect as the following: