How can I format the following output (Using cURL in PHP to parse a json object to an array and display properly formatted text in HTML)
function curlTwitch() {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.twitch.tv/kraken/streams/?game=Overwatch");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_HTTPHEADER, array (
'Accept: application/vnd.twitchtv.v5+json',
'Client-ID: x8j9dhw66qkgbsw67bfwtos4hyfeww'
));
$result = curl_exec($ch);
var_dump( json_decode($result, true) );
//echo json_encode($result, JSON_PRETTY_PRINT);
}
My current output fills the page in an unreadable format and is shown as something like:
array(2) { ["_total"]=> int(872) ["streams"]=> array(25) { [0]=> array(14) {
["_id"]=> int(30799425120) ["game"]=> string(9) "Overwatch"
["broadcast_platform"]=> string(4) "live" ["community_id"]=> string(0) ""
["community_ids"]=> array(0) { } ["viewers"]=> int(6104) ["video_height"]=>
int(900) ["average_fps"]=> int(60) ["delay"]=> int(0) ["created_at"]