PHP code example of dantepiazza / geo-location-data

1. Go to this page and download the library: Download dantepiazza/geo-location-data library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dantepiazza / geo-location-data example snippets


use Dantepiazza\GeoLocationData\Location;

$location = new Location();

// Regenerata a chache file
$location -> cache();

// Search locations by city name
$location -> search('Buenos Ai');

// Get location by city name
$location -> get(6344);

// Returns only the list of countries
$location -> countries();

// Get country by id
$location -> country('id', 11);

// Returns only the list of states
$location -> states();

// Get state by id
$location -> state(788);

// Returns only the list of counties in the country code
$location -> counties('AR');

// Get county by id
$location -> county('AR', 216);

// Returns only the list of cities in the country code
$location -> cities('AR');

// Get city by id
$location -> city('AR', 4867);

country_id: int
country_name: string
country_code: string
state_id: int
state_name: string
county_id: int
county_name: string
city_id: int
city_name: string
zip_code: string
name: string

id: int
code: string
name: string

id: int
country_id: int
name: string

id: int
country_id: int
state_id: int
name: string

id: int
country_id: int
state_id: int
county_id: int
zip_code: string
name: string