How to get the largest city of country using only the country code in PHP? [closed]

StackOverflow https://stackoverflow.com/questions/17475335

  •  02-06-2022
  •  | 
  •  

문제

i want to input the country code like "fr" and get the largest city "paris" , and if possible also the continent, in PHP !

도움이 되었습니까?

해결책

Extend to your needs, I already added the city you asked for:

$largest = [
    'fr' => 'paris',
];

$code = 'fr';

echo $largest[$code];

You can further improve this by wrapping it into a class supporting ArrayAccess giving a default value in case it does not exist.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top