PHP code example of michaelnjuguna / kenya-administrative-divisions

1. Go to this page and download the library: Download michaelnjuguna/kenya-administrative-divisions 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/ */

    

michaelnjuguna / kenya-administrative-divisions example snippets




ichaelNjuguna\KenyaAdministrativeDivisions\KenyaAdministrativeDivisions;

// Instantiate the class
$kenyaAdministrativeDivisions = new KenyaAdministrativeDivisions();


// Get All the data
$data = $kenyaAdministrativeDivisions->getAll();
print_r($data);

// Get all counties
$counties = $kenyaAdministrativeDivisions->getCounties();
print_r($counties);

// Get county information by passing the county code
$county = $kenyaAdministrativeDivisions->getCounties(1);
print_r($county);

// Get county information by passing the county name
$county = $kenyaAdministrativeDivisions->getCounties('Mombasa');
print_r($county);

// Get all constituencies
$constituencies = $kenyaAdministrativeDivisions->getConstituencies();
print_r($constituencies);

// Get constituencies of a particular county by its code
$constituencies = $kenyaAdministrativeDivisions->getConstituencies(1);
print_r($constituencies);

// Get constituencies of a particular county by its name
$constituencies = $kenyaAdministrativeDivisions->getConstituencies('Nairobi');
print_r($constituencies);


// Get all wards
$wards = $kenyaAdministrativeDivisions->getWards();
print_r($wards);

// Get wards of a particular county by passing its county code
$wards = $kenyaAdministrativeDivisions->getWards(1);
print_r($wards);

// Get wards of a particular county by passing its name
$wards = $kenyaAdministrativeDivisions->getWards('Mombasa');
print_r($wards);

// Get wards of a particular county and constituency by passing the respective county code/name and constituency name
$wards = $kenyaAdministrativeDivisions->getWards(1, 'Mvita');
$wards = $kenyaAdministrativeDivisions->getWards('Mombasa', 'Mvita');

// Get the wards of a particular constituency by passing its name
$wards = $kenyaAdministrativeDivisions->getWards(null, 'Mvita');
print_r($wards);