Here I have a JSON file, I would like to print this object in JSON format,
Json
[{"text": "Aachen, Germany - Aachen/Merzbruck (AAH)"}, {"text": "Aachen, Germany - Railway (ZIU)"}, {"text": "Aalborg, Denmark - Aalborg (AAL)"}, {"text": "Aalesund, Norway - Vigra (AES)"}, {"text": "Aarhus, Denmark - Aarhus Airport (AAR)"}, {"text": "Aarhus Limo, Denmark - Aarhus Limo (ZBU)"}, {"text": "Aasiaat, Greenland - Aasiaat (JEG)"}, {"text": "Abadan, Iran - Abadan (ABD)"}]
I tried the following way,
<?php $jsonurl='http://website.com/international.json'; $json = file_get_contents($jsonurl,0,null,null); $json_output = json_decode($json); foreach ($json_output as $trend) { echo "{$trend->text}\n"; } ?>
but it didnβt work, can someone help me understand what I am doing wrong.
source share