实例
<?php //删 $stu =array('id'=>6,'name'=>'xiaoli','age'=>29,'city'=>'厦门'); //返回删除的后面两元素 (array_splice($stu,2)); //保留的二个元素 print_r($stu); echo'<hr color="#FF0000">'; //改 $stu =array('id'=>6,'name'=>'xiaoli','age'=>29,'city'=>'厦门','学号'=>'2326'); (array_splice($stu,4,1,['李老师'])); print_r($stu); echo'<hr color="#FF0000">'; //增 $stu =array('id'=>6,'name'=>'xiaoli','age'=>29,'city'=>'厦门','学号'=>'2326'); array_splice($stu,4,0,['password']); print_r($stu); echo'<hr color="#FF0000">'; //查 $stu =array('id'=>6,'name'=>'xiaoli','age'=>29,'city'=>'厦门','学号'=>'2326'); print_r(array_splice($stu,2,1)); ?>
运行实例 »
点击 "运行实例" 按钮查看在线实例
手抄: