javascript - how to decode nested json in php -
i having json string like:
[ { "message": "test+sms", "sender": "test", "billcredit": "0.00", "messagestatus": "dnd", "sendondate": "2015-04-22 15:22:00", "provider": "aaaa" }, { "message": "test+sms", "sender": "test", "billcredit": "0.00", "messagestatus": "dnd", "sendondate": "2015-04-22 15:22:00", "provider": "aaa" }, { "message": "test+sms", "sender": "test", "billcredit": "1.00", "messagestatus": "delivrd", "sendondate": "2015-04-22 15:22:00", "provider": "aaaa" }, { "message": "test+sms", "sender": "test", "billcredit": "1.00", "messagestatus": "dnd rejected", "sendondate": "2015-04-22 15:22:00", "provider": "aaaa" } ]
i try doing this:
$objs = json_decode($data,true); foreach ($objs $obj){ $repor= $obj['messagestatus']; echo $repor;
but not working. please can me rid out of this. please me upload $repor sequentially in mysql.
working fine check $data='[{"message":"test+sms","sender":"execut","billcredit":"0.00","messagestatus":"dnd","sendondate":"2015-04-22 15:22:00","provider":"aaaa"},{"message":"test+sms","sender":"execut","billcredit":"0.00","messagestatus":"dnd","sendondate":"2015-04-22 15:22:00","provider":"aaa"},{"message":"test+sms","sender":"execut","billcredit":"1.00","messagestatus":"delivrd","sendondate":"2015-04-22 15:22:00","provider":"aaaa"},{"message":"test+sms","sender":"execut","billcredit":"1.00","messagestatus":"dnd rejected","sendondate":"2015-04-22 15:22:00","provider":"aaaa"}]'; $objs = json_decode($data, true); foreach ($objs $obj){ $repor= $obj['messagestatus']; echo $repor." "; } have placed single quotation around json array. nothing more.