PHP code example of brick / postcode

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

    

brick / postcode example snippets


use Brick\Postcode\PostcodeFormatter;

$formatter = new PostcodeFormatter();

$formatter->format('GB', 'WC2E9RZ'); // WC2E 9RZ
$formatter->format('US', '337014313'); // 33701-4313

  $formatter->format('GB', 'WC-2E9RZ'); // WC2E 9RZ
  

  $formatter->format('XX', '12345'); // UnknownCountryException
  

  $formatter->format('GB', 'ABCDEFG'); // InvalidPostcodeException