Questions about PHP JSON arrays

Source: Internet
Author: User
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);
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.