$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api-football-v1.p.rapidapi.com/v2/leagues",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"x-rapidapi-host: api-football-v1.p.rapidapi.com",
"x-rapidapi-key: 3444c7f813mshf9250f3690d1a26p13dc53jsnd4589e46851a"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
$response = json_decode($response);
foreach ($response->api->leagues as $value) {
if ($value->country == 'England') {
echo $value->league_id;
}
}
}