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,