The array_spilce function inserts the element at the specified position

$a = [1,2,4,5];

// 函数含义:从数组中移除选定的元素,并用新元素取代它。
array_splice($a,2,0,3);

print_r($a);

// [1,2,3,4,5]

//注意:只能处理索引数组,并且索引会重排

 

Guess you like

Origin blog.csdn.net/weixin_38230961/article/details/114031869