Right, there is no API endpoint that says “here’s all the channels you asked for and whether they are live or not”. There’s only “here’s the live channels out of what you asked for” or “here’s the users you asked for”. So to build the data of “who is live or not” you need to merge the input data and output data.
Example code:
// Fetch all the data we need
$live = array();
$channels = array("streamername");
$data = json_decode(@file_get_contents("https://api.twitch.tv/kraken/streams?channel=".implode(",",$channels)), true);
// Copy the channels we asked for into the composite associative array
foreach ($channels as $name) $live[$name] = null;
// Then copy the stream data into the composite associative array
foreach ($data["streams"] as $stream) $live[$stream["channel"]["login"]] = $stream["channel"];
foreach ($live as $name => $channel) {
if ($channel != null) {
echo "<a href=\"$channel['url']\">$channel["display_name"] - $channel["game"]</a> <img src=\"online.png\"> <br>";
} else {
echo "$name <img src=\"offline.png\"> <br>";
}
}