Embedding Twitch Viewer counter on website

This will work for you, but doesn’t do any error checking (ie. Is the stream offline? display 0 viewers)
(Disclaimer: I don’t claim to know or be good at writing PHP, I didn’t know how to do this without a foreach even though I didn’t want to use it, but hey… it works)

<?php $channel = "kittyplaysgames"; $dataArray = json_decode(@file_get_contents('https://api.twitch.tv/kraken/streams?channel='.$channel), true); foreach ($dataArray['streams'] as $mydata) { $viewers = $mydata['viewers']; }; echo "$channel has $viewers viewers"; ?>