Select value from JSON using PHP -
how select data bellow json code?
"response": { "status": 1, "httpstatus": 200, "data": [ { "offer_id": "8000", "countries": { "sg": { "id": "702", "code": "sg", "name": "singapore", "regions": [] } }
how select words sg , singapore
you can use json_decode function php. http://php.net/manual/en/function.json-decode.php
for exemple :
<?php $json = '{"response": { "status": 1, "httpstatus": 200, "data": [{ "offer_id": "8000", "countries": { "sg": { "id": "702", "code": "sg", "name": "singapore", "regions": [] } } }] }}'; $decode = json_decode($json); var_dump($decode->response->data[0]->sg->name);
Comments
Post a Comment