You can use this simple function for a cleaner PHP alternative:
function is_channel_live( $channel ) {
$twitchRequest = json_decode( @file_get_contents( 'https://api.twitch.tv/kraken/streams/' . $channel ) );
return ( ! is_null( $twitchRequest->stream ) ) ? TRUE : FALSE;
}
if (is_channel_live("swifty")) {
echo "WOO I'm live!";
}