1

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>
2
  • What is your question? Commented Jan 26, 2018 at 4:49
  • my question is how can i get the result from the json link in the php code? Commented Jan 26, 2018 at 4:50

2 Answers 2

3
$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>';
}
Sign up to request clarification or add additional context in comments.

6 Comments

Thankyou so much ;)
Do u have also any idee how can i get specific name or url? from the json?
I am quite new here so i do not know so much about the rules here. do u want me to take it back?
The last code u update it is not giving me any respons?
Glad I've helped
|
1

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>";
} 
?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.