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

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -