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

admin5年前php1151

可以看到数组格式在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过滤emod与特殊字符

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

mysql批量添加数据

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

php替换函数--数组写法

<?php  $my_name='&&&&'; //echo  substr(xml_entities(...

php设置16位的md5加密方法

用substr函数实现substr(md5(变量),8,16);就可以实现默认的md5(变量)输出的是32位加密方法...

php字符截取

substr(变量, 0,506)...

发表评论    

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