Simple Online/Offline Script Help Needed

Thank you JB940, that makes a little more sense to me. So would I be right in thinking my code should be altered as such:

<?php
$streamChannel = "mastersonothing";  
$url = "https://api.twitch.tv/kraken/streams?channel=mastersonothing"
$clientid = "12345678901234"

$json_array = json_decode(curl($url), true);  

$newurl = $url . "&client_id=" . $clientid;

if(isset($json_array['streams'][0]['channel'])) {  
echo "<div id='streamonline'>Stream is Online</div>";  
} else {  
echo "<div id='streamoffline'>Stream is Offline</div>";  
}  

?>

Or would I replace this section $json_array = json_decode(curl($url), true); with the newurl code?

Sorry if I’m being dense.