PHP code example of khartnett / address-normalization

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

    

khartnett / address-normalization example snippets



 use Khartnett\Normalization;
 $n = new Normalization();
 $result = $n->parse('204 southeast Smith Street Harrisburg, or 97446');
 /* result:
 [
     "number" => "204",
     "street" => "Smith",
     "street_type" => "St",
     "unit" => "",
     "unit_prefix" => "",
     "suffix" => "",
     "prefix" => "SE",
     "city" => "Harrisburg",
     "state" => "OR",
     "postal_code" => "97446",
     "postal_code_ext" => null,
     "street_type2" => null,
     "prefix2" => null,
     "suffix2" => null,
     "street2" => null,
 ] */
 $string_result = $n->parse('204 southeast Smith Street Harrisburg, or 97446', true);
  /* string_result:
  "204 SE Smith St, Harrisburg, OR 97446"
  */