Hi, I have this piece of code that checks if a live stream of a game is live or not. If it is live then it posts the players name who is streaming on a list where people can click to see his/her stream. The problem I am having is though is that it takes forever to load the page (probably because it takes so long to check the players streams). I was wondering if there was any way I could speed up the process and still keep what I want which is only the live users. Please, if you could answer with ease as I am still very new to this.
<?
$chan = "";
$streams = array( "meditor996", "malidude", "tacsecret", "izual155", "porkyhd", "tachydro#", "church_", "tainttubes", "kurimlinn", "TacvFOX", "tacpinkiepie", "dkrstarcraft", "chaoss tarcraft", "thepandrexlive", "zren89", "1soulfire", "sallvain", "sg_goldster", "adramelechii", "dragon", "dignitasselect", "sing_sing", "desrowfighting", "eghuk", "eg_idra", "rootcatz", "liquidsheth", "spanishiwa", "mtwdimaga", "whitera", "meditor996", "colqxc", "kraglord", "tsm_dyrus", "nyjacky", "crs_saintvicious", "tsm_theoddone", "mstephano", "protech", "tacmoose" );
echo '<br><br><font color="white"><b>Live User Streams:</b></font>';
foreach ($streams as &$i) {
$chan = "http://api.justin.tv/api/stream/list.json?channel=" . $i;
$json = @file_get_contents($chan);
$exist = strpos($json, 'name');
if($exist) {
$channelName = "$i"; //Set this to the channel name - all lowercase
$json_file = @file_get_contents("http://api.justin.tv/api/stream/list.json?channel={$channelName}", 0, null, null);
$json_array = json_decode($json_file, true);
if ($json_array[0]['name'] == "live_user_{$channelName}")
$live = true;
else
$live = false;
/*$gameSTR = "(" . $game . ")";*/
$userLINK = "<a href=\\"http://www.twitch.tv/$i \\" target=_blank title=$channelTitle style='color: #C0C0C0'>";
echo "<font style=tahoma color=white size=2>" . "<br>" . " " . " " . " " . $viewers . " " . $gameSTR . " " . $userLINK . $i . "</a>" . "</font>";
}
}
echo "</span>";
?>
Thanks in advance