Reputation: 67
I see there is some more questions about this, but not useful for me.
Here i have the link and following code i am Link
<?php
$json=file_get_contents("http://2strok.com/radio.json");
$details=json_decode($json);
if($details->Response=='True')
?>
<?php echo $details->name[3];?><br>
Upvotes: 1
Views: 71
Reputation: 12683
$json=file_get_contents("http://2strok.com/radio.json");
$details=json_decode($json,true);
foreach($details as $output) {
echo $output['name'].'<br>';
}
Update - get specific name
$json=file_get_contents("http://2strok.com/radio.json");
$details=json_decode($json,true);
foreach($details as $output) {
if ($output['name']=='FM 101 / Islamabad'){
echo 'Specific name found: '.$output['name'];
}
// echo $output['name'].'<br>';
}
Upvotes: 3
Reputation: 1464
After json decode, it returns an array of objects, so try this:
$json=file_get_contents("http://2strok.com/radio.json");
$details=json_decode($json);
foreach ($details as $detail){
echo $detail->name;
echo "<br>";
}
?>
Upvotes: 1