前言
删除数组里面的一个{}对象
比如
'[{"id":"666","name":"cyg","age":"27","subject":"海南学校"},{"id":"7777","name":"liwen","age":"21","subject":"北京学校"}]';
变成了(那个1是下标哈,外面的数组的下标哈)
{ "1": { "id": "7777", "name": "liwen", "age": "21", "subject": "北京学校" } }
cyg.php
<?php //删除数组里面的一个{}对象 $json_string= '[{"id":"666","name":"cyg","age":"27","subject":"海南学校"},{"id":"7777","name":"liwen","age":"21","subject":"北京学校"}]'; $data = json_decode($json_string,true);// 把JSON字符串转成PHP数组 unset($data[0]);//删除数组中下标0的对象 $json_strings = json_encode($data);//转换成json对象 var_dump($json_strings);//在输出
效果: