Formatting such a JSON string, how to write the syntax? Tokyu

Source: Internet
Author: User
Help: Formatting Such a JSON string, how to write the syntax? Tokyu )
For example, there is a two-dimensional array
$myarrnews =array ();
$myarrnews =explode ("| | **| | ", $MYSTR); Content from $MYSTR, including multiple news records
$myarrline =array ();
$myarrline =explode ("| | %%| | ", $myarrnews [$i]); $myarrline is one of these records, including multiple fields
Print_r ($myarrline); A collection of individual fields for each news, for example: Array ([0] = [1] = + 2166 [2] = innovation ...
You now need a JSON string with the format: (temporarily set to 5 per page)
{
"ret": 0,
"Data": {
"Newslist": [
{
"title": "1th News headline",
"Commentcount": 0,
"Source": "Origin",
"Nid": 10,
"Digest": "News Introduction",
"Ptime": "2012-03-28 14:11:43"
},
{
"title": "2nd news headline",
"Commentcount": 0,
"Source": "Origin",
"Nid": 9,
"Digest": "News Introduction",
"Ptime": "2012-03-28 13:12:56"
},
{
"title": "3rd News headline",
"Commentcount": 0,
"Source": "Origin",
"Nid": 8,
"Digest": "News Introduction",
"Ptime": "2012-03-28 12:21:11"
},
{
"title": "4th News headline",
"Commentcount": 0,
"Source": "Origin",
"Nid": 7,
"Digest": "News Introduction",
"Ptime": "2012-03-28 11:21:00"
},
{
"Title": "5th News headline",
"Commentcount": 1,
"Source": "Origin",
"Nid": 5,
"Digest": "News Introduction",
"Ptime": "2012-02-18 19:20:01"
}
],
"Totalnum": 5
},
"MSG": "OK"
}
//----------------------------
How do you write PHP syntax? Please help us, emergency!
------Solution--------------------
$ar = Arrat (

' Data ' = Array (
' Newslist ' = $newslist,
  • 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.