Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP json_decode not working properly
    primarykey
    data
    text
    <p>I am trying to use PHP's json_decode function to get a particular value from a json object. Sample code below:</p> <pre><code>foreach ($streams as &amp;$i) { $chan = "http://api.justin.tv/api/stream/list.json?channel=" . $i; $json = file_get_contents($chan); //Turns the gathered file information into a string for searching purposes. echo $json . " End of json variable.&lt;br&gt;"; $exist = strpos($json, 'name'); // Search the file/json object for the name attribute if($exist) { // Check to see if a name existed and if so add it to the live streams and get the image. echo " &lt;a href=\"http://justin.tv/" . $i . "\"&gt;" . $i . "&lt;/a&gt; &lt;br&gt;"; $liveStreams[$count] = $i; $json_information = json_decode($json,true); $image[$count] = $json_information[0]['channel']['image_url_large']; echo "Image link should appear: " . $image[count]; $count++; } } </code></pre> <p>So What I am trying to do with this is first and foremost gather which streams are active from a list provided earlier in the code. Second, if the stream is live, display a link to a page for it to be viewed(currently the justin.tv stream itself). What currently works is only the live streams will appear with links to them. What I need is to figure out why after decoding I cannot access the image_url_large variable. This is going to be a thumbnail view of the stream eventually.</p> <p>I have looked at various places for what should have worked and even on stackoverflow I saw the following thread:</p> <p><a href="https://stackoverflow.com/questions/1270016/json-decode-in-php">json decode in php</a></p> <p>I tried doing it like nickf's answer and it still isn't working. Any help would be greatly appreciated as well as staying within the array style instead of going into objects.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload