PHP Classes

File: city_to_province.php

Recommend this page to a friend!
  Classes of Ashraf Gheith   City to Province - Netherlands   city_to_province.php   Download  
File: city_to_province.php
Role: Class source
Content type: text/plain
Description: The main class
Class: City to Province - Netherlands
Get the province of a city of the Netherlands
Author: By
Last change: Changed variable definition
Date: 15 years ago
Size: 5,704 bytes
 

Contents

Class file image Download
<?php
/**
 * City to Province - Getting the province of a city in Netherlands
 *
 * @author Ashraf Gheith <nurazije@gmail.com>
 * @license http://www.php.net/license/2_02.txt The PHP License
 */
 
class city_to_province{
     public
$province_name;
    
     
/**
     * Set a constructor function, takes a city name and gives the province back
     *
     * @param string $city City name
     * @return string
     */
    
public function __construct($city){
        
$this->province_name = $this->province($this->province_code(ucwords($city)));
     }
    
    
/**
     * Set a private function to takes a city name and gives the province code
     *
     * @param string $city City name
     * @return string
     */
    
private function province_code($city){
            
$cities = array (
           
"Alblasserdam" => "Z-H",
           
"Alkmaar" => "N-H",
           
"Almelo" => "O",
           
"Almere" => "Fl",
           
"Almere-Haven" => "Fl",
           
"Alphen" => "Z-H",
           
"Amersfoort" => "U",
           
"Amsterdam" => "N-H",
           
"Apeldoorn" => "Gld",
           
"Arnhem" => "Gld",
           
"Arnhem-zuid" => "Gld",
           
"Assen" => "D",
           
"Baarn" => "U",
           
"Barendrecht" => "Z-H",
           
"Barneveld" => "Gld",
           
"Bergen op Zoom" => "N-B",
           
"Best" => "N-B",
           
"Beuningen" => "Gld",
           
"Blerick" => "L",
           
"Bodegraven" => "Z-H",
           
"Borne" => "O",
           
"Boxtel" => "N-B",
           
"Breda" => "N-B",
           
"Bunschoten" => "U",
           
"Bussum" => "N-H",
           
"Castricum" => "N-H",
           
"Cuijk" => "N-B",
           
"Culemborg" => "Gld",
           
"De Bilt" => "U",
           
"Delfzijl" => "Gr",
           
"De Meern" => "U",
           
"Den Helder" => "N-H",
           
"Deurne" => "N-B",
           
"Deventer" => "O",
           
"Dieren" => "Gld",
           
"Doetinchem" => "Gld",
           
"Dongen" => "N-B",
           
"Dordrecht" => "Z-H",
           
"Drachten" => "Fr",
           
"Driebergen-Rijsenburg" => "U",
           
"Dronten" => "Fl",
           
"Drunen" => "N-B",
           
"Duiven" => "Gld",
           
"Edam-Volendam" => "N-H",
           
"Ede" => "Gld",
           
"Eindhoven" => "N-B",
           
"Elst" => "Gld",
           
"Emmeloord" => "Fl",
           
"Emmen" => "D",
           
"Enkhuizen" => "N-H",
           
"Enschede" => "O",
           
"Ermelo" => "Gld",
           
"Etten-Leur" => "N-B",
           
"Geertruidenberg" => "N-B",
           
"Geldrop" => "N-B",
           
"Geleen" => "L",
           
"Goes" => "Z",
           
"Goirle" => "N-B",
           
"Gorinchem" => "Z-H",
           
"Gouda" => "Z-H",
           
"Groningen" => "Gr",
           
"Haaksbergen" => "O",
           
"Haarlem" => "N-H",
           
"Hardenberg" => "O",
           
"Harderwijk" => "Gld",
           
"Heerenveen" => "Fr",
           
"Heerhugowaard" => "N-H",
           
"Heerlen" => "L",
           
"Heiloo" => "N-H",
           
"Hellevoetsluis" => "Z-H",
           
"Helmond" => "N-B",
           
"Hendrik-Ido-Ambacht" => "Z-H",
           
"Hengelo" => "O",
           
"Hengelo-noord" => "O",
           
"Hillegom" => "Z-H",
           
"Hilversum" => "N-H",
           
"Hoofddorp" => "N-H",
           
"Hoogeveen" => "D",
           
"Hoogezand-Sappemeer" => "Gr",
           
"Hoogvliet" => "Z-H",
           
"Hoorn" => "N-H",
           
"Houten" => "U",
           
"Huizen" => "N-H",
           
"IJmuiden" => "N-H",
           
"IJsselstein" => "U",
           
"Kaatsheuvel" => "N-B",
           
"Kampen" => "O",
           
"Kerkrade" => "L",
           
"Laren" => "N-H",
           
"Leerdam" => "Z-H",
           
"Leeuwarden" => "Fr",
           
"Leiden" => "Z-H",
           
"Lelystad" => "Fl",
           
"Leusden" => "U",
           
"Lisse" => "Z-H",
           
"Maassluis" => "Z-H",
           
"Maastricht" => "L",
           
"Meppel" => "D",
           
"Middelburg" => "Z",
           
"Mijdrecht" => "U",
           
"Naaldwijk" => "Z-H",
           
"Nieuwegein" => "U",
           
"Nieuwerkerk" => "Z-H",
           
"Nieuw-Vennep" => "N-H",
           
"Nijkerk" => "Gld",
           
"Nijmegen" => "Gld",
           
"Nijverdal" => "O",
           
"Noordwijk" => "Z-H",
           
"Nuenen" => "N-B",
           
"Nunspeet" => "Gld",
           
"Oisterwijk" => "N-B",
           
"Oldenzaal" => "O",
           
"Oosterhout" => "N-B",
           
"Oss" => "N-B",
           
"Oud-Beijerland" => "Z-H",
           
"Pijnacker" => "Z-H",
           
"Purmerend" => "N-H",
           
"Putten" => "Gld",
           
"Raalte" => "O",
           
"Ridderkerk" => "Z-H",
           
"Rijssen" => "O",
           
"Roden" => "D",
           
"Roermond" => "L",
           
"Roosendaal" => "N-B",
           
"Rotterdam" => "Z-H",
           
"Schagen" => "N-H",
           
"Schijndel" => "N-B",
           
"Hague" => "Z-H",
           
"Gravenzande" => "Z-H",
           
"Hertogenbosch" => "N-B",
           
"Sittard" => "L",
           
"Sliedrecht" => "Z-H",
           
"Sneek" => "Fr",
           
"Soest" => "U",
           
"Spijkenisse" => "Z-H",
           
"Stadskanaal" => "Gr",
           
"Stede Broec" => "N-H",
           
"Steenwijk" => "O",
           
"Terneuzen" => "Z",
           
"Tiel" => "Gld",
           
"Tilburg" => "N-B",
           
"Uden" => "N-B",
           
"Uithoorn" => "N-H",
           
"Urk" => "Fl",
           
"Utrecht" => "U",
           
"Valkenswaard" => "N-B",
           
"Veendam" => "Gr",
           
"Veenendaal" => "U",
           
"Veghel" => "N-B",
           
"Velserbroek" => "N-H",
           
"Venlo" => "L",
           
"Venray" => "L",
           
"Vianen" => "Z-H",
           
"Vlissingen" => "Z",
           
"Waalwijk" => "N-B",
           
"Waddinxveen" => "Z-H",
           
"Wageningen" => "Gld",
           
"Weert" => "L",
           
"Weesp" => "N-H",
           
"Westervoort" => "Gld",
           
"Wijchen" => "Gld",
           
"Wijk" => "U",
           
"Winschoten" => "Gr",
           
"Winterswijk" => "Gld",
           
"Woerden" => "U",
           
"Zeewolde" => "Fl",
           
"Zeist" => "U",
           
"Zevenaar" => "Gld",
           
"Zoetermeer" => "Z-H",
           
"Zutphen" => "Gld",
           
"Zwolle" => "O"
       
);
             return
$cities[$city];
     }
    
    
/**
     * Set a private function to takes a province code and gives the province name
     *
     * @param string $code Province code
     * @return string
     */
    
private function province($code){
        
$provincies = array (
           
"D" => "Drenthe",
           
"Fl" => "Flevoland",
           
"Fr" => "Friesland",
           
"Gld" => "Gelderland",
           
"Gr" => "Groningen",
           
"L" => "Limburg",
           
"N-B" => "Noord-Brabant",
           
"N-H" => "Noord-Holland",
           
"O" => "Overijssel",
           
"U" => "Utrecht",
           
"Z" => "Zeeland",
           
"Z-H" => "Zuid-Holland"
       
);
         return
$provincies[$code];
     }
 }
?>