Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 帮助编辑JSON以生成数组而不是';字典';_Php_Mysql_Json - Fatal编程技术网

Php 帮助编辑JSON以生成数组而不是';字典';

Php 帮助编辑JSON以生成数组而不是';字典';,php,mysql,json,Php,Mysql,Json,我目前有一个来自mysql查询的json,它使用json_编码,如下所示: {"post_2":{"caption":"...","id":"...","accountID":"..","date":"07\/07\/2011 1:45:12 AM","title":"...","authorInfo":{"Email Address":"..."}}}, {"post_2":{"caption":"...","id":"...","accountID":"..","date":"07\/07\

我目前有一个来自mysql查询的json,它使用json_编码,如下所示:

{"post_2":{"caption":"...","id":"...","accountID":"..","date":"07\/07\/2011 1:45:12 AM","title":"...","authorInfo":{"Email Address":"..."}}}, {"post_2":{"caption":"...","id":"...","accountID":"..","date":"07\/07\/2011 1:45:12 AM","title":"...","authorInfo":{"Email Address":"..."}}}
我如何让json成为一个post数组(“post_2”、“post_1”)而不是一个字典?JSON将在iPhone上使用SBJSON进行解码,JSON必须在后端生成一个数组


感谢高级教程。

看看PHP的函数,如果需要数组,特别是第二个参数。

json\u encode()
提供一个非关联数组。最简单的方法通常是简单地调用(关联)数组上的
array\u values()
,并对结果进行编码。

我正在iPhone上使用SBJSON对其进行解码,我认为它们没有该功能;)我想你可能想改写你的问题。这个例子没有包含有效的JSON(它要么不完整,要么就是断章取义)。你说的非关联数组是什么意思?关联=数组(“a”=>“apple”,“b”=>“banana”),非关联=数组(“apple”,“banana”)