1. Go to this page and download the library: Download phdevutils/postal 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/ */
phdevutils / postal example snippets
use PhDevUtils\Postal\PostalCodes;
// Find by ZIP — always returns a list (PH ZIPs are not unique)
PostalCodes::findByZip('1000'); // [['zip'=>'1000','cityMun'=>'Manila','cityMunCode'=>'133900','region'=>'13', ...]]
PostalCodes::findByZip('6000'); // Cebu City → cityMunCode '072217'
// Find by city name (case-insensitive), optional filter
PostalCodes::findByCity('Davao City');
// List / count, filter by { zip, cityMunCode, province, region }
PostalCodes::list(['region' => '13']); // all NCR
PostalCodes::list(['cityMunCode' => '072217']); // all Cebu City ZIPs
PostalCodes::count(); // 2048
PostalCodes::count(['region' => '13']); // 360
[
'zip' => '1000',
'cityMun' => 'Manila',
'cityMunCode' => '133900', // 6-digit PSGC parent (joins phdevutils/core), or null if unmatched
'province' => null, // 4-digit, or null for NCR/HUC
'region' => '13', // 2-digit
'area' => null, // district/locality detail, or null
]
use PhDevUtils\Address;
$zip = PostalCodes::findByZip('6000')[0];
$city = Address::findCityMunicipality($zip['cityMunCode']); // ['name' => 'City of Cebu', 'province' => '0722', ...]
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.