我试图使用PHP的json_decode函数从json对象获取特定值.示例代码如下:
foreach ($streams as &$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.<br>";
$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 " <a href=\"http://justin.tv/" . $i . "\">" . $i . …Run Code Online (Sandbox Code Playgroud)