1. Go to this page and download the library: Download khush/india-pincodes 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/ */
khush / india-pincodes example snippets
use Khush\IndiaPincodes\IndiaState;
use Khush\IndiaPincodes\PincodeLookup;
$lookup = new PincodeLookup();
$offices = $lookup->find('401106'); // '401 106' works too
// [
// ['office' => 'Dongari', 'type' => 'BO', 'delivery' => true, 'district' => 'Thane', 'state' => 'MH'],
// ['office' => 'Uttan', 'type' => 'PO', 'delivery' => true, 'district' => 'Thane', 'state' => 'MH'],
// ]
IndiaState::NAMES_BY_CODE[$offices[0][PincodeLookup::STATE] ?? ''] ?? null; // 'Maharashtra' (state can be null)
$lookup->find('011001'); // null - malformed (a PIN never starts with 0)
$lookup->find('999999'); // null - unknown