Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear
select version() as Version;

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?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);
Copy Clear