具有多个json解析值的php数组

时间:2015-01-07 13:27:29

标签: php json

我编码显示从数据库中获取单个数组。我想显示多个数组值,如下所示

{"newrelease" : [{"model" : "apple 6", "image": " photo.jpg" , "specs": ""}] }

我已编码$response['New Releases' ][]['Model'][$b['PhoneModel']] =$b['FileName'];

,输出为{"New Releases":[{"Model":{"desire-x":"_htc-desire-x-dual-sim.jpg"}}

2 个答案:

答案 0 :(得分:0)

向您的array newrelease添加新的array

$response['newrelease'][] = array(
    'model' => $b['PhoneModel'],
    'image' => $b['FileName'],
    'specs' => ""
);
echo json_encode($response);

答案 1 :(得分:0)

这应该是我认为的伎俩:

$response['newrelease'][] = array("model" => "apple 6", "image" => " photo.jpg" , "specs" => "");