如何在PHP中解析json数据

时间:2016-06-08 07:18:13

标签: php json

[    
   { "Startdate": "2016-03-07T11:00:00+00:00", "Enddate": "2016-03-11T11:00:00+00:00" },
   { "Startdate": "2016-04-11T11:30:00+00:00", "Enddate": "2016-04-15T11:30:00+00:00" },
   { "Startdate": "2016-05-07T11:30:00+00:00", "Enddate": "2016-05-21T11:30:00+00:00" },
   { "Startdate": "2016-06-18T12:00:00+00:00", "Enddate": "2016-07-02T12:00:00+00:00" },
   { "Startdate": "2016-08-20T02:00:00+00:00", "Enddate": "2016-09-03T02:00:00+00:00" },
   { "Startdate": "2016-04-16T14:30:00+00:00", "Enddate": "2016-04-23T14:30:00+00:00" },
   { "price": "₹12,500.00" },
   { "price": "₹12,500.00" },
   { "price": "₹12,500.00" },
   { "price": "₹12,500.00" },
   { "price": "₹12,500.00" },
   { "price": "₹8,100.00"  }
]

我想要像这样输出

Startdate : 2016-06-18T12:00:00+00:00, Enddate : 2016-09-03T02:00:00+00:00 Price :\u20b912,500.00

Startdate : 2016-06-17T12:00:00+00:00, Enddate : 2016-09-03T02:00:00+00:00 Price :\u20b912,500.00

1 个答案:

答案 0 :(得分:0)

要解析php中的json数据,请使用json_decode。你拥有的不是一个有效的json。解析后,您可以使用foreach进行迭代。