语法:array_splice(array,start,length,array) ,start是从0开始标记,千万不要忘却。
把稳添加和修正时参数是4个,删除是3个参。

添加元素:

$array=array("你好","HELLO WORD","李雷PHP博客","学习","很快乐","是不是");echo "原数组:";var_dump($array);array_splice($array,1,0,"我是刚刚新添加的元素");echo "在第2位后添加元素:";var_dump($array);

删除元素:

php替换数组PHP中arraysplice函数对数组元素的添加修正删除 AJAX

$array=array("你好","HELLO WORD","李雷PHP博客","学习","很快乐","是不是");echo "原数组:";var_dump($array);array_splice($array,1,2);echo "从第2位开始删除2个元素:";var_dump($array);

修正元素:

$array=array("你好","HELLO WORD","李雷PHP博客","学习","很快乐","是不是");echo "原数组:";var_dump($array);array_splice($array,1,1,"我是刚刚新更换的元素");echo "将第2位后更换元素:";var_dump($array);