PHP JSON array problem
PHP json array problem, $result 1 and $result2 two arrays merged into one, output echo json_encode ($result 1) separately; Echo Json_encode ($result 2);
Final output effect:
{
"id": "111",
"Image_name": "My Bedroom",
"Image_url": "D:/image/a.png",
comments:[{
"UID", "122",
"CNAME": "Xiaoming",
"CTime", "2014-12-12",
}]
}
To do this, echo json_encode (Array ($result 1, $result 2)), so the output is not correct, it is added directly to the back, but not into a separate array
What should I do?
------to solve the idea----------------------
What are your $result 1, $result 2?
------to solve the idea----------------------
$result 1 = Array (
' id ' = ' 111 ',
' Image_name ' = ' my bedroom ',
' Image_url ' = ' d:/image/a.png '
);
$result 2 = Array (
' Comments ' = array (
Array
' UID ' = ' 122 ',
' CNAME ' = ' xiaoming ',
' CTime ' = ' 2014-12-12 '
)
)
);
$result = Array_merge ($result 1, $result 2);
echo Json_encode ($result);