Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
$url = "https://restcountries.com/v3.1/all";
$data = file_get_contents($url);
$json = json_decode($data, true);
$x = 1;
foreach($json as $v){
if(isset($v['capital'])){
if(is_array($v['capital'])){
foreach($v['capital'] as $d){
if (mb_substr($d, 0, 1) === "A")
echo $x." - ".$d."\n";
$x++;
}
}
}
}
#print_r($v);