PHP Classes

PHP GeoLocation Country: Get country coordinates using the country code

Recommend this page to a friend!
  Info   View files Example   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 151 All time: 9,069 This week: 59Up
Version License PHP version Categories
code2latlon 1.0.0GNU General Publi...5PHP 5, Geography


This class can get country coordinates using the country code.

It can take country code as parameters and returns the latitude and longitude coordinates of the country capital city obtained from a data file.

The class may also get the country coordinates using the country identifier number.

Innovation Award
PHP Programming Innovation award nominee
October 2021
Number 10
There is a particular type of application that needs to use the location of the capital city of each country.

This package can provide information about the capital cities of all countries of the world.

That information comes from a data file provided by this package, so it does not require an external Web service to provide that information.

Manuel Lemos
Picture of Dixan Santiesteban
  Performance   Level  
Name: Dixan Santiesteban <contact>
Classes: 1 package by
Country: Cuba Cuba
Age: 47
All time rank: 427412 in Cuba Cuba
Week rank: 225 Up2 in Cuba Cuba Up
Innovation award
Innovation award
Nominee: 1x


include 'code2latlon.class.php';
$latlon = new Code2latlon;
$latlon->get('CU'); # return ["23.11666667","-82.35"]
echo $latlon->getByIndex(51); # return ["23.11666667","-82.35"] :)

  Files folder image Files  
File Role Description
Plain text file code2latlon.class.php Class the class file
Accessible without login Plain text file latlon.dat Data data
Accessible without login Plain text file sample.php Example Example script

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:9,069
This week:59Up