0) { $LastPage = false; $NetflixJson .= json_encode(json_decode($Result, true)["viewedItems"]) . ","; } else { $LastPage = true; $NetflixJson = substr($NetflixJson, 0, -1); } curl_close($ch); $CurPage++; } print_r($NetflixJson . "]");