Getting viewer count with php and curl

shove a print_r($json_array); after this and you can debug you own script.

or just use the solution provided.

Helix api returns a JSON object with a key of data. and data is always an array, so you need to refer to the first entry in said array