NGStatesLGA: Nigerian 36 States & Local Government Areas PHP Class

Recently a friend of mine complained about this – not seeing States and LGA online for developers’ use. I took it upon myself to make this available to us and make work easier for us.

It took me 3hrs to arrange it, which my source was from this site, thanks to them 🙂

How to use this
I tried to make it easier for us which I created a class that can help in sorting the data, start with

<?php
require_once( 'NGStatesLGA/class.php');
$data = new NGStatesLGA();
print_r( $data->getLGA( 'Abia' ) );

This returns array containing the Local Governments and the State Capital.
If you wish to get total LGA count or Capital

echo $data->totalLGA
echo $data->capital

Get LGA State
This is an interesting part of it, just pass the LGA name as an argument and it returns the State it belongs to 🙂

echo $data->getLGAState( 'Ohafia' );

Returns Abia.

Get Capital’s State:
Similar as the above, this one returns the State name when a Capital name is passed as an argument

echo $data->getCapitalState( 'Umuahia' );

Output
This can return PHP array or JSON, if you specify at the class initialization

<?php $data = new NGStateLGA( JSON );

Default is PHP_ARRAY.

Get this
https://github.com/donjajo/NGStatesLGA
Credits to – http://www.waado.org/nigerdelta/nigeria_facts/States_LocalGovtAreas.html

Posted in: