For smart Primates & ROBOTS (oh and ALIENS ).

Blogroll

Friday, February 05, 2016

JSON parse in PHP

JSON parse in PHP



Suppose you want to parse listed below JSON data in PHP and you only needed to print objectId values. you can see here 3 records under merchants value "RPEZF3MRM39Z0"

-----------------------------------------------------------------------
{
"appId": "0QA16KMMVJAQR",
"merchants": {
"RPEZF3MRM39Z0": [{
"objectId": "O:S1MXC6FCY6GDW",
"type": "UPDATE",
"ts": 1453110818494
}, {
"objectId": "O:S1MXC6FCY6GDW",
"type": "UPDATE",
"ts": 1453110818913
}, {
"objectId": "P:SYD46NHH64EQG",
"type": "CREATE",
"ts": 1453110818913
}]
}
}
------------------------------------------------------------------------

php code:

suppose $st is hlding the above json data.

$json_a=json_decode($st,true);
foreach ( $json_a['merchants']['RPEZF3MRM39Z0'] as $objectId )
{
    echo $objectId['objectId']."</br>";
}




Share:

0 comments:

Post a Comment

How to make center align child div

 How to make center align child div?   Suppose you have 2 Div tag. And want the make inner tag center <div id="d1">      ...

Ads Inside Post

Powered by Blogger.

Arsip