Source for file examples1.php
Documentation is available at examples1.php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
* This file is part of the PEAR Services_GeoNames package.
* LICENSE: This source file is subject to the MIT license that is available
* through the world-wide-web at the following URI:
* http://opensource.org/licenses/mit-license.php
* @package Services_GeoNames
* @author David Jean Louis <izi@php.net>
* @copyright 2008-2009 David Jean Louis
* @license http://opensource.org/licenses/mit-license.php MIT License
* @version CVS: $Id: examples1.php 274374 2009-01-23 14:21:59Z izi $
* @link http://pear.php.net/package/Services_GeoNames
* @link http://www.geonames.org/export/webservice-exception.html
* @since File available since release 0.1.0
* Include the geonames package.
require_once 'Services/GeoNames.php';
// search for all cities named 'Paris'
$cities = $geo->search (array ('name_equals' => 'Paris'));
echo "List of cities named Paris:\n";
foreach ($cities as $city) {
printf(" - %s (%s)\n", $city->name , $city->countryName );
// find all postal codes near by "Toulouse" in a radius of 10km
$postalCodes = $geo->findNearbyPostalCodes (array (
echo "List of postal codes near by Toulouse in a radius of 10km:\n";
foreach ($postalCodes as $code) {
printf(" - %s (%s)\n", $code->postalCode , $code->placeName );
// get the list of all countries and capitals in spanish
$countries = $geo->countryInfo (array ('lang' => 'es'));
echo "List of all countries in spanish language:\n";
foreach ($countries as $country) {
printf(" - %s (capital: %s)\n", $country->countryName , $country->capital );
// get the neightbours countries of France
$array = $geo->countryInfo (array ('country' => 'FR'));
$neighbours = $geo->neighbours (array ('geonameId' => $france->geonameId ));
echo "Neighbours of France are:\n";
foreach ($neighbours as $neighbour) {
printf(" - %s\n", $neighbour->countryName );
Documentation generated on Mon, 11 Mar 2019 15:39:14 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|