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

admin5年前php1311

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


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

相关文章

php的function函数内部只能有一个return

php的function函数内部只能有一个return,之后的代码就都全部运行不正常了...

php post undefined index,PHP 中提示undefined index的解决方案

声明为空isset($_POST['user_email']),或者,empty($_POST['user_email'])在php.ini中设置error_repor...

短地址生成,全套配置教程

短地址生成,全套配置教程

nginx 配置location / {rewrite  ^(.*)$  /index.php?s=/$1  last;}code rotoo.top.7z...

php调用chatgpd接口输出

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

面向过程的php sqlhelp

<?php $servername = "localhost"; $username = "root"; $...

php替换ASCIII码空格字符的方法

需要用到PHP自带函数chr()方法如下:$string=str_replace(chr(0x01),"",$string);...

发表评论    

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