如何将多个json组合成一个?
程序员文章站
2024-04-06 17:51:37
...
$question = $_GET['question']; $arr = explode("|",$question); for($i = 0;$i
这是查询的语句[{"rid":"1","title":"\u6211\u662f\u8c01","a":"\u5b8b\u5411\u4e1c","b":"\u9b4f\u4eae","c":"\u738b\u514b\u5a07","d":"\u5b8b\u5b50\u6587","answer":"\u5b8b\u5411\u4e1c"}][{"rid":"2","title":"\u6211\u662f\u8c01","a":"\u9b4f\u4eae","b":"\u5218\u5fb7\u534e","c":"\u674e\u5a1c","d":"\u5f20\u626c","answer":"\u9b4f\u4eae"}][{"rid":"3","title":"\u6211\u662f\u8c01","a":"\u9b4f\u4eae","b":"\u738b\u514b\u5a07","c":"\u674e\u56fd\u4f1f","d":"\u738b\u83f2","answer":"\u738b\u514b\u5a07"}][{"rid":"16","title":"\u6211\u662f\u8c01","a":"\u5218\u5f66\u5bbe","b":"\u674e\u56fd\u632f","c":"\u7a0b\u79c0\u82b9","d":"\u738b\u514b\u5a07","answer":"\u738b\u514b\u5a07"}]
查询出来的结果。 如何把这三个json组合成一个?[{"rid":"1","title":"\u6211\u662f\u8c01","a":"\u5b8b\u5411\u4e1c","b":"\u9b4f\u4eae","c":"\u738b\u514b\u5a07","d":"\u5b8b\u5b50\u6587","answer":"\u5b8b\u5411\u4e1c"},{"rid":"2","title":"\u6211\u662f\u8c01","a":"\u9b4f\u4eae","b":"\u5218\u5fb7\u534e","c":"\u674e\u5a1c","d":"\u5f20\u626c","answer":"\u9b4f\u4eae"},{"rid":"3","title":"\u6211\u662f\u8c01","a":"\u9b4f\u4eae","b":"\u738b\u514b\u5a07","c":"\u674e\u56fd\u4f1f","d":"\u738b\u83f2","answer":"\u738b\u514b\u5a07"},{"rid":"16","title":"\u6211\u662f\u8c01","a":"\u5218\u5f66\u5bbe","b":"\u674e\u56fd\u632f","c":"\u7a0b\u79c0\u82b9","d":"\u738b\u514b\u5a07","answer":"\u738b\u514b\u5a07"}]
保存成这样的。
回复讨论(解决方案)
转数组 然后合成一个数组 再转json
把 $ar[] = $row;
改为 $ar[$i][] = $row;
把
$js = json_encode($ar);
echo $js;
移到 for 循环后面谢谢。
上一篇: HTML段落的作用及教程
推荐阅读
-
如何将多个json组合成一个?
-
如何将一个HTML页面嵌套在多个动态页面(asp) 博客分类: Javascript asp
-
django rest framework如何一次性序列化同一个数据库下多个model表数据在一个json页面下
-
Asp.Net如何将多个RadioButton指定在一个组中
-
Asp.Net如何将多个RadioButton指定在一个组中
-
在做一个ios端接口,对方传来多个json字符串,我应该如何将json数据与数据库数据做匹配?
-
如何将一个String和多个String值进行比较思路分析_javascript技巧
-
如何将多个excel表合成一个excel
-
在做一个ios端接口,对方传来多个json字符串,小弟我应该怎么将json数据与数据库数据做匹配
-
在做一个ios端接口,对方传来多个json字符串,小弟我应该怎么将json数据与数据库数据做匹配