Parsing nested JSON with PHP -


{     "listing": {         "@attributes": {             "domain": "example.com"         },         "tld": "com",         "sld": "example",         "owner": "john smith"     } } 

i needing iterate through json array , put values php variables can return values.

example:

echo $sld; 

would print:

example

would need foreach loop (and if how format this) or there easy built in function such extract() this?

<?php  $json = '{     "listing": {         "@attributes": {             "domain": "example.com"         },         "tld": "com",         "sld": "example",         "owner": "john smith"     } }';  $decoded_array = json_decode($json, true); echo $decoded_array['listing']['sld'];//example ?>  

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -