0
$channels = array('imaqtpies','imsoff','zzero71tv', 'kaptenen', 'onlySinged', 'nightblue3') ;
$nr = 0;
$callAPI = implode(",",$channels);
$online = 'online.png';
$offline = 'offline.png';
$json = file_get_contents('https://api.twitch.tv/kraken/streams?channel=' . $callAPI);
$dataArray = json_decode($json, true);
foreach($dataArray['streams'] as $mydata){
echo $mydata['channel']['name'] . ' is online';
echo '<br /><hr />';
unset($channels[$nr]);
$nr++;
}
$newChannels = array_values($channels);;
foreach($newChannels as $channel) {
echo $channel . ' is offline';
echo '<br /><hr />';
}
並非所有名稱都在「脫機」部分中回顯,並且有些名稱正在兩次(在線和脫機狀態下)回顯。陣列不會刪除所有元素