PHP code example of divineomega / php-postcodes

1. Go to this page and download the library: Download divineomega/php-postcodes 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/ */

    

divineomega / php-postcodes example snippets


$postcodeLookupService = new \DivineOmega\Postcodes\Objects\IdealPostcodes('API_KEY');
// OR
$postcodeLookupService = new \DivineOmega\Postcodes\Objects\PostcodeAnywhere('API_KEY');
// OR
$postcodeLookupService = new \DivineOmega\Postcodes\Objects\PostcodesIo();

$addresses = $postcodeLookupService->getAddressesByPostcode('ST163DP');

$validated = \DivineOmega\Postcodes\Utils\Validator::validatePostcode('ST163DP');

$postcode = \DivineOmega\Postcodes\Utils\Generator::generatePostcode();

$outwardCode = \DivineOmega\Postcodes\Utils\Tokenizer::outward('ST163DP'); // Returns ST16
$inwardCode = \DivineOmega\Postcodes\Utils\Tokenizer::inward('ST163DP'); // Returns 3DP