把一个索引数组内的某个元素删除后直接转成json输出,数据格式不正确

admin4年前php942

可以看到数组格式在unset后发生变化 解决方法很简单 仅一行代码就可以解决
在foreach后 增加
$arr = array_values($arr);


转至:https://blog.csdn.net/tingting0805/article/details/72974431

相关文章

php调用chatgpd接口输出

<?php $url = 'https://api.openai.com/v1/completions'; $data = arr...

php数组元素的增加删除修改操作方法

增加$arr[$iy]["pr_count"]+=$pr_count;减少$arr[$iy]["pr_count"]-=$pr_count;删除unset($a...

mysql批量添加数据

$conn=new sqlhelper;for ($i = 0; $i <1000 ; $i++) {$sql="insert into system_user(user_shenfe...

php过滤emod与特殊字符

<?php  function xml_entities($string) { //过滤emod $ts_zifu= json_encode($st...

php再调用json_decode从字符串对象生成json对象时出现Cannot use object of type stdClass as array解决方法

php再调用json_decode从字符串对象生成json对象时,如果使用[]操作符取数据,会得到下面的错误:Cannot use object of type stdClass as array产生...

php设置跨站访问

  php的open_basedir设置多个路径(目录),分隔符是“:”冒号open_basedir=/www/wwwroot/www.ceshi.com/:/tmp/:/www/...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。