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
Post a Comment