FileMaker Postal Address Standardization

filemakerpostaladdress

Have you ever wanted to Standardize a postal address to post office specifications? There's a great php script available here:

http://www.analysisandsolutions.com/software/addr/addr.htm

One of the things that this script does is to take all the different abbreviations that people use and convert them to standards. Below you can see a few of these and HUNDREDS more handled in the PHP script below.

'APARTMENT' => 'APT',
'APT-R' => 'APARTMENT',
'APT' => 'APT',
'BLDG' => 'BLDG',
'BUILDING' => 'BLDG',
'BLDG-R' => 'BUILDING',
'BOX' => 'BOX',
'BOX-R' => 'BOX',
'BASEMENT' => 'BSMT',
'BSMT-R' => 'BASEMENT',
'BSMT' => 'BSMT',
'DEPARTMENT' => 'DEPT',
'DEPT-R' => 'DEPARTMENT',
'DEPT' => 'DEPT',
'FL' => 'FL',
'FLOOR' => 'FL'


To update our addresses, we set each line of the address using a FileMaker Custom Function which then uses the Scodigo PHP plugin to process a PHP script. The FileMaker script updates each line of the address. We update it in the following order as we have an automatic lookup of the City and State when Zipcodes are entered...

Set Field [ ContactsAddress::Zip; phpAddressStandardization ( ContactsAddress::Zip ) ]
Set Field [ ContactsAddress::City; phpAddressStandardization ( ContactsAddress::City ) ]
Set Field [ ContactsAddress::State; phpAddressStandardization ( ContactsAddress::State ) ]
Set Field [ ContactsAddress::Address; phpAddressStandardization ( ContactsAddress::Address ) ]
Set Field [ ContactsAddress::Country; phpAddressStandardization ( ContactsAddress::Country ) ]

The Custom Function is as follows. You pass in one part of the address to it and it returns that part using the Post Office Standardization rules. Currently, we store the "AddressLineStandardization" PHP script, seen further below, in a global field called "Settings::PHPAddressStandardization" which is initialized at startup. If we were to redo this today, we would probable create a table of scripts for any html, php, javascript, groovy script, or any other external code that we may need. Even better would be to convert this to a Groovy script to make it an External Function using ScriptMaster from 360Works.

Set Field [ ContactsAddress::Zip; phpAddressStandardization ( ContactsAddress::Zip ) ]
Set Field [ ContactsAddress::City; phpAddressStandardization ( ContactsAddress::City ) ]
Set Field [ ContactsAddress::State; phpAddressStandardization ( ContactsAddress::State ) ]
Set Field [ ContactsAddress::Address; phpAddressStandardization ( ContactsAddress::Address ) ]
Set Field [ ContactsAddress::Country; phpAddressStandardization ( ContactsAddress::Country ) ]
The Custom Function is as follows. You pass in one part of the address to it and it returns that part using the Post Office Standardization rules. Currently, we store the "AddressLineStandardization" PHP script, seen further below, in a global field called "Settings::PHPAddressStandardization" which is initialized at startup. If we were to redo this today, we would probable create a table of scripts for any html, php, javascript, groovy script, or any other external code that we may need. Even better would be to convert this to a Groovy script to make it an External Function using ScriptMaster from 360Works.
//
// phpAddressStandardization ( AddressLine )
//
// Standardize a Line of an Address.
//
Let ( [
$AddressLine = AddressLine ; // use in the phpCode like so: fm_evaluate( '$AddressLine' )
phpCode =
GetField ( "Settings::PHPAddressStandardization" ) & "
/**¶
* Address Standardization Solution, PHP Edition,¶
* AddressLineStandardization() Usage Example.¶

* @package AddressStandardizationSolution¶
* @author Daniel Convissor ¶
* @copyright The Analysis and Solutions Company, 2001-2006¶
* @version $Name: rel-5-5 $ $Id: addr-tx_ex-standard.php,v 5.3 2006/03/18 17:46:08 danielc Exp $¶
* @link http://www.analysisandsolutions.com/software/addr/addr.htm¶
*/¶

/**¶
* Require the main file.¶
*/¶

$Address = new AddressStandardizationSolution;¶
echo $Address->AddressLineStandardization(fm_evaluate( '$AddressLine' ));¶
"
] ;
PHP_Execute(phpCode)
)

Finally, below you can either download the php script directly from analysisandsolutions.com or get it below. The script below is EXACTLY what we have in our global field called "Settings::PHPAddressStandardization". This field is only referenced in the Custom Function.

http://www.analysisandsolutions.com/software/download/

/**
* Address Standardization Solution, PHP Edition.
*
*
Aids processing of United States postal address data.
*
*
Takes a Delivery Address Line entered by a user and reformats it to
* conform with the United States Postal Service's Addressing Standards.
*
*
The class also contains a state list generator for use in XHTML forms.
*
*
Requires PHP 4 or later.
*
*
Address Standardization Solution is a trademark of The Analysis
* and Solutions Company.
*
*
* ======================================================================
* SIMPLE PUBLIC LICENSE VERSION 1.1 2003-01-21
*
* Copyright (c) The Analysis and Solutions Company
* http://www.analysisandsolutions.com/
*
* 1. Permission to use, copy, modify, and distribute this software and
* its documentation, with or without modification, for any purpose and
* without fee or royalty is hereby granted, provided that you include
* the following on ALL copies of the software and documentation or
* portions thereof, including modifications, that you make:
*
* a. The full text of this license in a location viewable to users
* of the redistributed or derivative work.
*
* b. Notice of any changes or modifications to the files,
* including the date changes were made.
*
* 2. The name, servicemarks and trademarks of the copyright holders
* may NOT be used in advertising or publicity pertaining to the
* software without specific, written prior permission.
*
* 3. Title to copyright in this software and any associated
* documentation will at all times remain with copyright holders.
*
* 4. THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND
* COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY
* OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE
* OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS,
* COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
*
* 5. COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DAMAGES, INCLUDING
* BUT NOT LIMITED TO, DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL,
* ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
* ======================================================================
*
*
* @package AddressStandardizationSolution
* @author Daniel Convissor
* @copyright The Analysis and Solutions Company, 2001-2006
* @version $Name: rel-5-5 $ $Id: addr-tx.inc,v 5.7 2006/03/18 17:46:08 danielc Exp $
* @link http://www.analysisandsolutions.com/software/addr/addr.htm
*/
/**
* Aids processing of United States postal address data.
*
*
Please consider making a contribution to support our open source
* development. See the link below.
*
* @package AddressStandardizationSolution
* @author Daniel Convissor
* @copyright The Analysis and Solutions Company, 2001-2006
* @version $Name: rel-5-5 $
* @link http://www.analysisandsolutions.com/software/addr/addr.htm
* @link http://www.analysisandsolutions.com/contribute/
* @license http://www.analysisandsolutions.com/software/license.htm Simple Public License
*/
class AddressStandardizationSolution {
/**
* Array with state names as keys and abbreviations as values.
* @var array
*/
var $States = array();
/**
* Array with street types as keys and abbreviations as values.
* @var array
*/
var $Suffixes = array();
/**
* Array with room types as keys and abbreviations as values.
* @var array
*/
var $Identifiers = array();
/**
* Array with compass directions as keys and abbreviations as values.
* @var array
*/
var $Directionals = array();
/**
* Array with as numeric words keys and integers as values.
* @var array
*/
var $Numbers = array();
/**
* Constructor method, setting the data arrays needed for the class.
*
* @return void
*/
function AddressStandardizationSolution() {
$this->Directionals = array(
'E' => 'E',
'EAST' => 'E',
'E-R' => 'EAST',
'N' => 'N',
'NO' => 'N',
'NORTH' => 'N',
'N-R' => 'NORTH',
'NE' => 'NE',
'NORTHEAST' => 'NE',
'NE-R' => 'NORTHEAST',
'NORTHWEST' => 'NW',
'NW-R' => 'NORTHWEST',
'NW' => 'NW',
'S' => 'S',
'SO' => 'S',
'SOUTH' => 'S',
'S-R' => 'SOUTH',
'SE' => 'SE',
'SOUTHEAST' => 'SE',
'SE-R' => 'SOUTHEAST',
'SOUTHWEST' => 'SW',
'SW-R' => 'SOUTHWEST',
'SW' => 'SW',
'W' => 'W',
'WEST' => 'W',
'W-R' => 'WEST',
);
$this->Numbers = array(
'FIRST' => '1',
'ONE' => '1',
'TEN' => '10',
'TENTH' => '10',
'ELEVEN' => '11',
'ELEVENTH' => '11',
'TWELFTH' => '12',
'TWELVE' => '12',
'THIRTEEN' => '13',
'THIRTEENTH' => '13',
'FOURTEEN' => '14',
'FOURTEENTH' => '14',
'FIFTEEN' => '15',
'FIFTEENTH' => '15',
'SIXTEEN' => '16',
'SIXTEENTH' => '16',
'SEVENTEEN' => '17',
'SEVENTEENTH' => '17',
'EIGHTEEN' => '18',
'EIGHTEENTH' => '18',
'NINETEEN' => '19',
'NINETEENTH' => '19',
'SECOND' => '2',
'TWO' => '2',
'TWENTIETH' => '20',
'TWENTY' => '20',
'THIRD' => '3',
'THREE' => '3',
'FOUR' => '4',
'FOURTH' => '4',
'FIFTH' => '5',
'FIVE' => '5',
'SIX' => '6',
'SIXTH' => '6',
'SEVEN' => '7',
'SEVENTH' => '7',
'EIGHT' => '8',
'EIGHTH' => '8',
'NINE' => '9',
'NINTH' => '9',
);
$this->States = array(
'ARMED FORCES AMERICA' => 'AA',
'ARMED FORCES EUROPE' => 'AE',
'ALASKA' => 'AK',
'ALABAMA' => 'AL',
'ARMED FORCES PACIFIC' => 'AP',
'ARKANSAS' => 'AR',
'ARIZONA' => 'AZ',
'CALIFORNIA' => 'CA',
'COLORADO' => 'CO',
'CONNECTICUT' => 'CT',
'DISTRICT OF COLUMBIA' => 'DC',
'DELAWARE' => 'DE',
'FLORIDA' => 'FL',
'GEORGIA' => 'GA',
'HAWAII' => 'HI',
'IOWA' => 'IA',
'IDAHO' => 'ID',
'ILLINOIS' => 'IL',
'INDIANA' => 'IN',
'KANSAS' => 'KS',
'KENTUCKY' => 'KY',
'LOUISIANA' => 'LA',
'MASSACHUSETTS' => 'MA',
'MARYLAND' => 'MD',
'MAINE' => 'ME',
'MICHIGAN' => 'MI',
'MINNESOTA' => 'MN',
'MISSOURI' => 'MO',
'MISSISSIPPI' => 'MS',
'MONTANA' => 'MT',
'NORTH CAROLINA' => 'NC',
'NORTH DAKOTA' => 'ND',
'NEBRASKA' => 'NE',
'NEW HAMPSHIRE' => 'NH',
'NEW JERSEY' => 'NJ',
'NEW MEXICO' => 'NM',
'NEVADA' => 'NV',
'NEW YORK' => 'NY',
'OHIO' => 'OH',
'OKLAHOMA' => 'OK',
'OREGON' => 'OR',
'PENNSYLVANIA' => 'PA',
'RHODE ISLAND' => 'RI',
'SOUTH CAROLINA' => 'SC',
'SOUTH DAKOTA' => 'SD',
'TENNESSEE' => 'TN',
'TEXAS' => 'TX',
'UTAH' => 'UT',
'VIRGINIA' => 'VA',
'VERMONT' => 'VT',
'WASHINGTON' => 'WA',
'WISCONSIN' => 'WI',
'WEST VIRGINIA' => 'WV',
'WYOMING' => 'WY',
);
$this->Identifiers = array(
'APARTMENT' => 'APT',
'APT-R' => 'APARTMENT',
'APT' => 'APT',
'BLDG' => 'BLDG',
'BUILDING' => 'BLDG',
'BLDG-R' => 'BUILDING',
'BOX' => 'BOX',
'BOX-R' => 'BOX',
'BASEMENT' => 'BSMT',
'BSMT-R' => 'BASEMENT',
'BSMT' => 'BSMT',
'DEPARTMENT' => 'DEPT',
'DEPT-R' => 'DEPARTMENT',
'DEPT' => 'DEPT',
'FL' => 'FL',
'FLOOR' => 'FL',
'FL-R' => 'FLOOR',
'FRNT' => 'FRNT',
'FRONT' => 'FRNT',
'FRNT-R' => 'FRONT',
'HANGER' => 'HNGR',
'HNGR-R' => 'HANGER',
'HNGR' => 'HNGR',
'KEY' => 'KEY',
'KEY-R' => 'KEY',
'LBBY' => 'LBBY',
'LOBBY' => 'LBBY',
'LBBY-R' => 'LOBBY',
'LOT' => 'LOT',
'LOT-R' => 'LOT',
'LOWER' => 'LOWR',
'LOWR-R' => 'LOWER',
'LOWR' => 'LOWR',
'OFC' => 'OFC',
'OFFICE' => 'OFC',
'OFC-R' => 'OFFICE',
'PENTHOUSE' => 'PH',
'PH-R' => 'PENTHOUSE',
'PH' => 'PH',
'PIER' => 'PIER',
'PIER-R' => 'PIER',
'PMB' => 'PMB',
'PMB-R' => 'PMB',
'REAR' => 'REAR',
'REAR-R' => 'REAR',
'RM' => 'RM',
'ROOM' => 'RM',
'RM-R' => 'ROOM',
'SIDE' => 'SIDE',
'SIDE-R' => 'SIDE',
'SLIP' => 'SLIP',
'SLIP-R' => 'SLIP',
'SPACE' => 'SPC',
'SPC-R' => 'SPACE',
'SPC' => 'SPC',
'STE' => 'STE',
'SUITE' => 'STE',
'STE-R' => 'SUITE',
'STOP' => 'STOP',
'STOP-R' => 'STOP',
'TRAILER' => 'TRLR',
'TRLR-R' => 'TRAILER',
'TRLR' => 'TRLR',
'UNIT' => 'UNIT',
'UNIT-R' => 'UNIT',
'UPPER' => 'UPPR',
'UPPR-R' => 'UPPER',
'UPPR' => 'UPPR',
'UPR' => 'UPPR',
);
$this->Suffixes = array(
'ALLEE' => 'ALY',
'ALLEY' => 'ALY',
'ALY-R' => 'ALLEY',
'ALLY' => 'ALY',
'ALY' => 'ALY',
'ANEX' => 'ANX',
'ANNEX' => 'ANX',
'ANX-R' => 'ANNEX',
'ANNX' => 'ANX',
'ANX' => 'ANX',
'ARC' => 'ARC',
'ARCADE' => 'ARC',
'ARC-R' => 'ARCADE',
'AV' => 'AVE',
'AVE' => 'AVE',
'AVEN' => 'AVE',
'AVENU' => 'AVE',
'AVENUE' => 'AVE',
'AVE-R' => 'AVENUE',
'AVN' => 'AVE',
'AVNUE' => 'AVE',
'BCH' => 'BCH',
'BEACH' => 'BCH',
'BCH-R' => 'BEACH',
'BG' => 'BG',
'BURG' => 'BG',
'BG-R' => 'BURG',
'BGS' => 'BGS',
'BURGS' => 'BGS',
'BGS-R' => 'BURGS',
'BLF' => 'BLF',
'BLUF' => 'BLF',
'BLUFF' => 'BLF',
'BLF-R' => 'BLUFF',
'BLFS' => 'BLFS',
'BLUFFS' => 'BLFS',
'BLFS-R' => 'BLUFFS',
'BLVD' => 'BLVD',
'BLVRD' => 'BLVD',
'BOUL' => 'BLVD',
'BOULEVARD' => 'BLVD',
'BLVD-R' => 'BOULEVARD',
'BOULOVARD' => 'BLVD',
'BOULV' => 'BLVD',
'BOULVRD' => 'BLVD',
'BULAVARD' => 'BLVD',
'BULEVARD' => 'BLVD',
'BULLEVARD' => 'BLVD',
'BULOVARD' => 'BLVD',
'BULVD' => 'BLVD',
'BEND' => 'BND',
'BND-R' => 'BEND',
'BND' => 'BND',
'BR' => 'BR',
'BRANCH' => 'BR',
'BR-R' => 'BRANCH',
'BRNCH' => 'BR',
'BRDGE' => 'BRG',
'BRG' => 'BRG',
'BRGE' => 'BRG',
'BRIDGE' => 'BRG',
'BRG-R' => 'BRIDGE',
'BRK' => 'BRK',
'BROOK' => 'BRK',
'BRK-R' => 'BROOK',
'BRKS' => 'BRKS',
'BROOKS' => 'BRKS',
'BRKS-R' => 'BROOKS',
'BOT' => 'BTM',
'BOTTM' => 'BTM',
'BOTTOM' => 'BTM',
'BTM-R' => 'BOTTOM',
'BTM' => 'BTM',
'BYP' => 'BYP',
'BYPA' => 'BYP',
'BYPAS' => 'BYP',
'BYPASS' => 'BYP',
'BYP-R' => 'BYPASS',
'BYPS' => 'BYP',
'BAYOO' => 'BYU',
'BAYOU' => 'BYU',
'BYU-R' => 'BAYOU',
'BYO' => 'BYU',
'BYOU' => 'BYU',
'BYU' => 'BYU',
'CIR' => 'CIR',
'CIRC' => 'CIR',
'CIRCEL' => 'CIR',
'CIRCL' => 'CIR',
'CIRCLE' => 'CIR',
'CIR-R' => 'CIRCLE',
'CRCL' => 'CIR',
'CRCLE' => 'CIR',
'CIRCELS' => 'CIRS',
'CIRCLES' => 'CIRS',
'CIRS-R' => 'CIRCLES',
'CIRCLS' => 'CIRS',
'CIRCS' => 'CIRS',
'CIRS' => 'CIRS',
'CRCLES' => 'CIRS',
'CRCLS' => 'CIRS',
'CLB' => 'CLB',
'CLUB' => 'CLB',
'CLB-R' => 'CLUB',
'CLF' => 'CLF',
'CLIF' => 'CLF',
'CLIFF' => 'CLF',
'CLF-R' => 'CLIFF',
'CLFS' => 'CLFS',
'CLIFFS' => 'CLFS',
'CLFS-R' => 'CLIFFS',
'CLIFS' => 'CLFS',
'CMN' => 'CMN',
'COMMON' => 'CMN',
'CMN-R' => 'COMMON',
'COMN' => 'CMN',
'COR' => 'COR',
'CORN' => 'COR',
'CORNER' => 'COR',
'COR-R' => 'CORNER',
'CRNR' => 'COR',
'CORNERS' => 'CORS',
'CORS-R' => 'CORNERS',
'CORNRS' => 'CORS',
'CORS' => 'CORS',
'CRNRS' => 'CORS',
'CAMP' => 'CP',
'CP-R' => 'CAMP',
'CMP' => 'CP',
'CP' => 'CP',
'CAPE' => 'CPE',
'CPE-R' => 'CAPE',
'CPE' => 'CPE',
'CRECENT' => 'CRES',
'CRES' => 'CRES',
'CRESCENT' => 'CRES',
'CRES-R' => 'CRESCENT',
'CRESENT' => 'CRES',
'CRSCNT' => 'CRES',
'CRSENT' => 'CRES',
'CRSNT' => 'CRES',
'CK' => 'CRK',
'CR' => 'CRK',
'CREEK' => 'CRK',
'CRK-R' => 'CREEK',
'CREK' => 'CRK',
'CRK' => 'CRK',
'COARSE' => 'CRSE',
'COURSE' => 'CRSE',
'CRSE-R' => 'COURSE',
'CRSE' => 'CRSE',
'CREST' => 'CRST',
'CRST-R' => 'CREST',
'CRST' => 'CRST',
'CAUSEWAY' => 'CSWY',
'CSWY-R' => 'CAUSEWAY',
'CAUSEWY' => 'CSWY',
'CAUSWAY' => 'CSWY',
'CAUSWY' => 'CSWY',
'CSWY' => 'CSWY',
'CORT' => 'CT',
'COURT' => 'CT',
'CT-R' => 'COURT',
'CRT' => 'CT',
'CT' => 'CT',
'CEN' => 'CTR',
'CENT' => 'CTR',
'CENTER' => 'CTR',
'CTR-R' => 'CENTER',
'CENTR' => 'CTR',
'CENTRE' => 'CTR',
'CNTER' => 'CTR',
'CNTR' => 'CTR',
'CTR' => 'CTR',
'CENS' => 'CTRS',
'CENTERS' => 'CTRS',
'CTRS-R' => 'CENTERS',
'CENTRES' => 'CTRS',
'CENTRS' => 'CTRS',
'CENTS' => 'CTRS',
'CNTERS' => 'CTRS',
'CNTRS' => 'CTRS',
'CTRS' => 'CTRS',
'COURTS' => 'CTS',
'CTS-R' => 'COURTS',
'CTS' => 'CTS',
'CRV' => 'CURV',
'CURV' => 'CURV',
'CURVE' => 'CURV',
'CURV-R' => 'CURVE',
'COV' => 'CV',
'COVE' => 'CV',
'CV-R' => 'COVE',
'CV' => 'CV',
'COVES' => 'CVS',
'CVS-R' => 'COVES',
'COVS' => 'CVS',
'CVS' => 'CVS',
'CAN' => 'CYN',
'CANYN' => 'CYN',
'CANYON' => 'CYN',
'CYN-R' => 'CANYON',
'CNYN' => 'CYN',
'CYN' => 'CYN',
'DAL' => 'DL',
'DALE' => 'DL',
'DL-R' => 'DALE',
'DL' => 'DL',
'DAM' => 'DM',
'DM-R' => 'DAM',
'DM' => 'DM',
'DR' => 'DR',
'DRIV' => 'DR',
'DRIVE' => 'DR',
'DR-R' => 'DRIVE',
'DRV' => 'DR',
'DRIVES' => 'DRS',
'DRS-R' => 'DRIVES',
'DRIVS' => 'DRS',
'DRS' => 'DRS',
'DRVS' => 'DRS',
'DIV' => 'DV',
'DIVD' => 'DV',
'DIVID' => 'DV',
'DIVIDE' => 'DV',
'DV-R' => 'DIVIDE',
'DV' => 'DV',
'DVD' => 'DV',
'EST' => 'EST',
'ESTA' => 'EST',
'ESTATE' => 'EST',
'EST-R' => 'ESTATE',
'ESTAS' => 'ESTS',
'ESTATES' => 'ESTS',
'ESTS-R' => 'ESTATES',
'ESTS' => 'ESTS',
'EXP' => 'EXPY',
'EXPR' => 'EXPY',
'EXPRESS' => 'EXPY',
'EXPRESSWAY' => 'EXPY',
'EXPY-R' => 'EXPRESSWAY',
'EXPRESWAY' => 'EXPY',
'EXPRSWY' => 'EXPY',
'EXPRWY' => 'EXPY',
'EXPW' => 'EXPY',
'EXPWY' => 'EXPY',
'EXPY' => 'EXPY',
'EXWAY' => 'EXPY',
'EXWY' => 'EXPY',
'EXT' => 'EXT',
'EXTEN' => 'EXT',
'EXTENSION' => 'EXT',
'EXT-R' => 'EXTENSION',
'EXTENSN' => 'EXT',
'EXTN' => 'EXT',
'EXTNSN' => 'EXT',
'EXTENS' => 'EXTS',
'EXTENSIONS' => 'EXTS',
'EXTS-R' => 'EXTENSIONS',
'EXTENSNS' => 'EXTS',
'EXTNS' => 'EXTS',
'EXTNSNS' => 'EXTS',
'EXTS' => 'EXTS',
'FAL' => 'FALL',
'FALL' => 'FALL',
'FALL-R' => 'FALL',
'FIELD' => 'FLD',
'FLD-R' => 'FIELD',
'FLD' => 'FLD',
'FIELDS' => 'FLDS',
'FLDS-R' => 'FIELDS',
'FLDS' => 'FLDS',
'FALLS' => 'FLS',
'FLS-R' => 'FALLS',
'FALS' => 'FLS',
'FLS' => 'FLS',
'FLAT' => 'FLT',
'FLT-R' => 'FLAT',
'FLT' => 'FLT',
'FLATS' => 'FLTS',
'FLTS-R' => 'FLATS',
'FLTS' => 'FLTS',
'FORD' => 'FRD',
'FRD-R' => 'FORD',
'FRD' => 'FRD',
'FORDS' => 'FRDS',
'FRDS-R' => 'FORDS',
'FRDS' => 'FRDS',
'FORG' => 'FRG',
'FORGE' => 'FRG',
'FRG-R' => 'FORGE',
'FRG' => 'FRG',
'FORGES' => 'FRGS',
'FRGS-R' => 'FORGES',
'FRGS' => 'FRGS',
'FORK' => 'FRK',
'FRK-R' => 'FORK',
'FRK' => 'FRK',
'FORKS' => 'FRKS',
'FRKS-R' => 'FORKS',
'FRKS' => 'FRKS',
'FOREST' => 'FRST',
'FRST-R' => 'FOREST',
'FORESTS' => 'FRST',
'FORREST' => 'FRST',
'FORRESTS' => 'FRST',
'FORRST' => 'FRST',
'FORRSTS' => 'FRST',
'FORST' => 'FRST',
'FORSTS' => 'FRST',
'FRRESTS' => 'FRST',
'FRRST' => 'FRST',
'FRRSTS' => 'FRST',
'FRST' => 'FRST',
'FERRY' => 'FRY',
'FRY-R' => 'FERRY',
'FERY' => 'FRY',
'FRRY' => 'FRY',
'FRY' => 'FRY',
'FORT' => 'FT',
'FT-R' => 'FORT',
'FRT' => 'FT',
'FT' => 'FT',
'FREEWAY' => 'FWY',
'FWY-R' => 'FREEWAY',
'FREEWY' => 'FWY',
'FREWAY' => 'FWY',
'FREWY' => 'FWY',
'FRWAY' => 'FWY',
'FRWY' => 'FWY',
'FWY' => 'FWY',
'GARDEN' => 'GDN',
'GDN-R' => 'GARDEN',
'GARDN' => 'GDN',
'GDN' => 'GDN',
'GRDEN' => 'GDN',
'GRDN' => 'GDN',
'GARDENS' => 'GDNS',
'GDNS-R' => 'GARDENS',
'GARDNS' => 'GDNS',
'GDNS' => 'GDNS',
'GRDENS' => 'GDNS',
'GRDNS' => 'GDNS',
'GLEN' => 'GLN',
'GLN-R' => 'GLEN',
'GLENN' => 'GLN',
'GLN' => 'GLN',
'GLENNS' => 'GLNS',
'GLENS' => 'GLNS',
'GLNS-R' => 'GLENS',
'GLNS' => 'GLNS',
'GREEN' => 'GRN',
'GRN-R' => 'GREEN',
'GREN' => 'GRN',
'GRN' => 'GRN',
'GREENS' => 'GRNS',
'GRNS-R' => 'GREENS',
'GRENS' => 'GRNS',
'GRNS' => 'GRNS',
'GROV' => 'GRV',
'GROVE' => 'GRV',
'GRV-R' => 'GROVE',
'GRV' => 'GRV',
'GROVES' => 'GRVS',
'GRVS-R' => 'GROVES',
'GROVS' => 'GRVS',
'GRVS' => 'GRVS',
'GATEWAY' => 'GTWY',
'GTWY-R' => 'GATEWAY',
'GATEWY' => 'GTWY',
'GATWAY' => 'GTWY',
'GTWAY' => 'GTWY',
'GTWY' => 'GTWY',
'HARB' => 'HBR',
'HARBOR' => 'HBR',
'HBR-R' => 'HARBOR',
'HARBR' => 'HBR',
'HBR' => 'HBR',
'HRBOR' => 'HBR',
'HARBORS' => 'HBRS',
'HBRS-R' => 'HARBORS',
'HBRS' => 'HBRS',
'HILL' => 'HL',
'HL-R' => 'HILL',
'HL' => 'HL',
'HILLS' => 'HLS',
'HLS-R' => 'HILLS',
'HLS' => 'HLS',
'HLLW' => 'HOLW',
'HLLWS' => 'HOLW',
'HOLLOW' => 'HOLW',
'HOLW-R' => 'HOLLOW',
'HOLLOWS' => 'HOLW',
'HOLOW' => 'HOLW',
'HOLOWS' => 'HOLW',
'HOLW' => 'HOLW',
'HOLWS' => 'HOLW',
'HEIGHT' => 'HTS',
'HEIGHTS' => 'HTS',
'HTS-R' => 'HEIGHTS',
'HGTS' => 'HTS',
'HT' => 'HTS',
'HTS' => 'HTS',
'HAVEN' => 'HVN',
'HVN-R' => 'HAVEN',
'HAVN' => 'HVN',
'HVN' => 'HVN',
'HIGHWAY' => 'HWY',
'HWY-R' => 'HIGHWAY',
'HIGHWY' => 'HWY',
'HIWAY' => 'HWY',
'HIWY' => 'HWY',
'HWAY' => 'HWY',
'HWY' => 'HWY',
'HYGHWAY' => 'HWY',
'HYWAY' => 'HWY',
'HYWY' => 'HWY',
'INLET' => 'INLT',
'INLT-R' => 'INLET',
'INLT' => 'INLT',
'ILAND' => 'IS',
'ILND' => 'IS',
'IS' => 'IS',
'ISLAND' => 'IS',
'IS-R' => 'ISLAND',
'ISLND' => 'IS',
'ILE' => 'ISLE',
'ISLE' => 'ISLE',
'ISLE-R' => 'ISLE',
'ISLES' => 'ISLE',
'ILANDS' => 'ISS',
'ILNDS' => 'ISS',
'ISLANDS' => 'ISS',
'ISS-R' => 'ISLANDS',
'ISLDS' => 'ISS',
'ISLNDS' => 'ISS',
'ISS' => 'ISS',
'JCT' => 'JCT',
'JCTION' => 'JCT',
'JCTN' => 'JCT',
'JUNCTION' => 'JCT',
'JCT-R' => 'JUNCTION',
'JUNCTN' => 'JCT',
'JUNCTON' => 'JCT',
'JCTIONS' => 'JCTS',
'JCTNS' => 'JCTS',
'JCTS' => 'JCTS',
'JUNCTIONS' => 'JCTS',
'JCTS-R' => 'JUNCTIONS',
'JUNCTONS' => 'JCTS',
'JUNGTNS' => 'JCTS',
'KNL' => 'KNL',
'KNOL' => 'KNL',
'KNOLL' => 'KNL',
'KNL-R' => 'KNOLL',
'KNLS' => 'KNLS',
'KNOLLS' => 'KNLS',
'KNLS-R' => 'KNOLLS',
'KNOLS' => 'KNLS',
'KEY' => 'KY',
'KY-R' => 'KEY',
'KY' => 'KY',
'KEYS' => 'KYS',
'KYS-R' => 'KEYS',
'KYS' => 'KYS',
'LAND' => 'LAND',
'LAND-R' => 'LAND',
'LCK' => 'LCK',
'LOCK' => 'LCK',
'LCK-R' => 'LOCK',
'LCKS' => 'LCKS',
'LOCKS' => 'LCKS',
'LCKS-R' => 'LOCKS',
'LDG' => 'LDG',
'LDGE' => 'LDG',
'LODG' => 'LDG',
'LODGE' => 'LDG',
'LDG-R' => 'LODGE',
'LF' => 'LF',
'LOAF' => 'LF',
'LF-R' => 'LOAF',
'LGT' => 'LGT',
'LIGHT' => 'LGT',
'LGT-R' => 'LIGHT',
'LT' => 'LGT',
'LGTS' => 'LGTS',
'LIGHTS' => 'LGTS',
'LGTS-R' => 'LIGHTS',
'LTS' => 'LGTS',
'LAKE' => 'LK',
'LK-R' => 'LAKE',
'LK' => 'LK',
'LAKES' => 'LKS',
'LKS-R' => 'LAKES',
'LKS' => 'LKS',
'LA' => 'LN',
'LANE' => 'LN',
'LN-R' => 'LANE',
'LANES' => 'LN',
'LN' => 'LN',
'LNS' => 'LN',
'LANDG' => 'LNDG',
'LANDING' => 'LNDG',
'LNDG-R' => 'LANDING',
'LANDNG' => 'LNDG',
'LNDG' => 'LNDG',
'LNDNG' => 'LNDG',
'LOOP' => 'LOOP',
'LOOP-R' => 'LOOP',
'LOOPS' => 'LOOP',
'MALL' => 'MALL',
'MALL-R' => 'MALL',
'MDW' => 'MDW',
'MEADOW' => 'MDW',
'MDW-R' => 'MEADOW',
'MDWS' => 'MDWS',
'MEADOWS' => 'MDWS',
'MDWS-R' => 'MEADOWS',
'MEDOWS' => 'MDWS',
'MEDWS' => 'MDWS',
'MEWS' => 'MEWS',
'MEWS-R' => 'MEWS',
'MIL' => 'ML',
'MILL' => 'ML',
'ML-R' => 'MILL',
'ML' => 'ML',
'MILLS' => 'MLS',
'MLS-R' => 'MILLS',
'MILS' => 'MLS',
'MLS' => 'MLS',
'MANOR' => 'MNR',
'MNR-R' => 'MANOR',
'MANR' => 'MNR',
'MNR' => 'MNR',
'MANORS' => 'MNRS',
'MNRS-R' => 'MANORS',
'MANRS' => 'MNRS',
'MNRS' => 'MNRS',
'MISN' => 'MSN',
'MISSION' => 'MSN',
'MSN-R' => 'MISSION',
'MISSN' => 'MSN',
'MSN' => 'MSN',
'MSSN' => 'MSN',
'MNT' => 'MT',
'MOUNT' => 'MT',
'MT-R' => 'MOUNT',
'MT' => 'MT',
'MNTAIN' => 'MTN',
'MNTN' => 'MTN',
'MOUNTAIN' => 'MTN',
'MTN-R' => 'MOUNTAIN',
'MOUNTIN' => 'MTN',
'MTIN' => 'MTN',
'MTN' => 'MTN',
'MNTNS' => 'MTNS',
'MOUNTAINS' => 'MTNS',
'MTNS-R' => 'MOUNTAINS',
'MTNS' => 'MTNS',
'MOTORWAY' => 'MTWY',
'MTWY-R' => 'MOTORWAY',
'MOTORWY' => 'MTWY',
'MOTRWY' => 'MTWY',
'MOTWY' => 'MTWY',
'MTRWY' => 'MTWY',
'MTWY' => 'MTWY',
'NCK' => 'NCK',
'NECK' => 'NCK',
'NCK-R' => 'NECK',
'NEK' => 'NCK',
'OPAS' => 'OPAS',
'OVERPAS' => 'OPAS',
'OVERPASS' => 'OPAS',
'OPAS-R' => 'OVERPASS',
'OVERPS' => 'OPAS',
'OVRPS' => 'OPAS',
'ORCH' => 'ORCH',
'ORCHARD' => 'ORCH',
'ORCH-R' => 'ORCHARD',
'ORCHRD' => 'ORCH',
'OVAL' => 'OVAL',
'OVAL-R' => 'OVAL',
'OVL' => 'OVAL',
'PARK' => 'PARK',
'PARK-R' => 'PARK',
'PARKS' => 'PARK',
'PK' => 'PARK',
'PRK' => 'PARK',
'PAS' => 'PASS',
'PASS' => 'PASS',
'PASS-R' => 'PASS',
'PATH' => 'PATH',
'PATH-R' => 'PATH',
'PATHS' => 'PATH',
'PIKE' => 'PIKE',
'PIKE-R' => 'PIKE',
'PIKES' => 'PIKE',
'PARKWAY' => 'PKWY',
'PKWY-R' => 'PARKWAY',
'PARKWAYS' => 'PKWY',
'PARKWY' => 'PKWY',
'PKWAY' => 'PKWY',
'PKWY' => 'PKWY',
'PKWYS' => 'PKWY',
'PKY' => 'PKWY',
'PL' => 'PL',
'PLAC' => 'PL',
'PLACE' => 'PL',
'PL-R' => 'PLACE',
'PLASE' => 'PL',
'PLAIN' => 'PLN',
'PLN-R' => 'PLAIN',
'PLN' => 'PLN',
'PLAINES' => 'PLNS',
'PLAINS' => 'PLNS',
'PLNS-R' => 'PLAINS',
'PLNS' => 'PLNS',
'PLAZ' => 'PLZ',
'PLAZA' => 'PLZ',
'PLZ-R' => 'PLAZA',
'PLZ' => 'PLZ',
'PLZA' => 'PLZ',
'PZ' => 'PLZ',
'PINE' => 'PNE',
'PNE-R' => 'PINE',
'PNE' => 'PNE',
'PINES' => 'PNES',
'PNES-R' => 'PINES',
'PNES' => 'PNES',
'PR' => 'PR',
'PRAIR' => 'PR',
'PRAIRIE' => 'PR',
'PR-R' => 'PRAIRIE',
'PRARE' => 'PR',
'PRARIE' => 'PR',
'PRR' => 'PR',
'PRRE' => 'PR',
'PORT' => 'PRT',
'PRT-R' => 'PORT',
'PRT' => 'PRT',
'PORTS' => 'PRTS',
'PRTS-R' => 'PORTS',
'PRTS' => 'PRTS',
'PASG' => 'PSGE',
'PASSAGE' => 'PSGE',
'PSGE-R' => 'PASSAGE',
'PASSG' => 'PSGE',
'PSGE' => 'PSGE',
'PNT' => 'PT',
'POINT' => 'PT',
'PT-R' => 'POINT',
'PT' => 'PT',
'PNTS' => 'PTS',
'POINTS' => 'PTS',
'PTS-R' => 'POINTS',
'PTS' => 'PTS',
'RAD' => 'RADL',
'RADIAL' => 'RADL',
'RADL-R' => 'RADIAL',
'RADIEL' => 'RADL',
'RADL' => 'RADL',
'RAMP' => 'RAMP',
'RAMP-R' => 'RAMP',
'RD' => 'RD',
'ROAD' => 'RD',
'RD-R' => 'ROAD',
'RDG' => 'RDG',
'RDGE' => 'RDG',
'RIDGE' => 'RDG',
'RDG-R' => 'RIDGE',
'RDGS' => 'RDGS',
'RIDGES' => 'RDGS',
'RDGS-R' => 'RIDGES',
'RDS' => 'RDS',
'ROADS' => 'RDS',
'RDS-R' => 'ROADS',
'RIV' => 'RIV',
'RIVER' => 'RIV',
'RIV-R' => 'RIVER',
'RIVR' => 'RIV',
'RVR' => 'RIV',
'RANCH' => 'RNCH',
'RNCH-R' => 'RANCH',
'RANCHES' => 'RNCH',
'RNCH' => 'RNCH',
'RNCHS' => 'RNCH',
'RAOD' => 'ROAD',
'ROW' => 'ROW',
'ROW-R' => 'ROW',
'RAPID' => 'RPD',
'RPD-R' => 'RAPID',
'RPD' => 'RPD',
'RAPIDS' => 'RPDS',
'RPDS-R' => 'RAPIDS',
'RPDS' => 'RPDS',
'REST' => 'RST',
'RST-R' => 'REST',
'RST' => 'RST',
'ROUTE' => 'RTE',
'RTE-R' => 'ROUTE',
'RT' => 'RTE',
'RTE' => 'RTE',
'RUE' => 'RUE',
'RUE-R' => 'RUE',
'RUN' => 'RUN',
'RUN-R' => 'RUN',
'SHL' => 'SHL',
'SHOAL' => 'SHL',
'SHL-R' => 'SHOAL',
'SHOL' => 'SHL',
'SHLS' => 'SHLS',
'SHOALS' => 'SHLS',
'SHLS-R' => 'SHOALS',
'SHOLS' => 'SHLS',
'SHOAR' => 'SHR',
'SHORE' => 'SHR',
'SHR-R' => 'SHORE',
'SHR' => 'SHR',
'SHOARS' => 'SHRS',
'SHORES' => 'SHRS',
'SHRS-R' => 'SHORES',
'SHRS' => 'SHRS',
'SKWY' => 'SKWY',
'SKYWAY' => 'SKWY',
'SKWY-R' => 'SKYWAY',
'SKYWY' => 'SKWY',
'SMT' => 'SMT',
'SUMIT' => 'SMT',
'SUMITT' => 'SMT',
'SUMMIT' => 'SMT',
'SMT-R' => 'SUMMIT',
'SUMT' => 'SMT',
'SPG' => 'SPG',
'SPNG' => 'SPG',
'SPRING' => 'SPG',
'SPG-R' => 'SPRING',
'SPRNG' => 'SPG',
'SPGS' => 'SPGS',
'SPNGS' => 'SPGS',
'SPRINGS' => 'SPGS',
'SPGS-R' => 'SPRINGS',
'SPRNGS' => 'SPGS',
'SPR' => 'SPUR',
'SPRS' => 'SPUR',
'SPUR' => 'SPUR',
'SPUR-R' => 'SPUR',
'SPURS' => 'SPUR',
'SQ' => 'SQ',
'SQAR' => 'SQ',
'SQR' => 'SQ',
'SQRE' => 'SQ',
'SQU' => 'SQ',
'SQUARE' => 'SQ',
'SQ-R' => 'SQUARE',
'SQARS' => 'SQS',
'SQRS' => 'SQS',
'SQS' => 'SQS',
'SQUARES' => 'SQS',
'SQS-R' => 'SQUARES',
'ST' => 'ST',
'STR' => 'ST',
'STREET' => 'ST',
'ST-R' => 'STREET',
'STRT' => 'ST',
'STA' => 'STA',
'STATION' => 'STA',
'STA-R' => 'STATION',
'STATN' => 'STA',
'STN' => 'STA',
'STRA' => 'STRA',
'STRAV' => 'STRA',
'STRAVE' => 'STRA',
'STRAVEN' => 'STRA',
'STRAVENUE' => 'STRA',
'STRA-R' => 'STRAVENUE',
'STRAVN' => 'STRA',
'STRVN' => 'STRA',
'STRVNUE' => 'STRA',
'STREAM' => 'STRM',
'STRM-R' => 'STREAM',
'STREME' => 'STRM',
'STRM' => 'STRM',
'STREETS' => 'STS',
'STS-R' => 'STREETS',
'STS' => 'STS',
'TER' => 'TER',
'TERACE' => 'TER',
'TERASE' => 'TER',
'TERR' => 'TER',
'TERRACE' => 'TER',
'TER-R' => 'TERRACE',
'TERRASE' => 'TER',
'TERRC' => 'TER',
'TERRICE' => 'TER',
'TPK' => 'TPKE',
'TPKE' => 'TPKE',
'TRNPK' => 'TPKE',
'TRPK' => 'TPKE',
'TURNPIKE' => 'TPKE',
'TPKE-R' => 'TURNPIKE',
'TURNPK' => 'TPKE',
'TRACK' => 'TRAK',
'TRAK-R' => 'TRACK',
'TRACKS' => 'TRAK',
'TRAK' => 'TRAK',
'TRK' => 'TRAK',
'TRKS' => 'TRAK',
'TRACE' => 'TRCE',
'TRCE-R' => 'TRACE',
'TRACES' => 'TRCE',
'TRCE' => 'TRCE',
'TRAFFICWAY' => 'TRFY',
'TRFY-R' => 'TRAFFICWAY',
'TRAFFICWY' => 'TRFY',
'TRAFWAY' => 'TRFY',
'TRFCWY' => 'TRFY',
'TRFFCWY' => 'TRFY',
'TRFFWY' => 'TRFY',
'TRFWY' => 'TRFY',
'TRFY' => 'TRFY',
'TR' => 'TRL',
'TRAIL' => 'TRL',
'TRL-R' => 'TRAIL',
'TRAILS' => 'TRL',
'TRL' => 'TRL',
'TRLS' => 'TRL',
'THROUGHWAY' => 'TRWY',
'TRWY-R' => 'THROUGHWAY',
'THROUGHWY' => 'TRWY',
'THRUWAY' => 'TRWY',
'THRUWY' => 'TRWY',
'THRWAY' => 'TRWY',
'THRWY' => 'TRWY',
'THWY' => 'TRWY',
'TRWY' => 'TRWY',
'TUNEL' => 'TUNL',
'TUNL' => 'TUNL',
'TUNLS' => 'TUNL',
'TUNNEL' => 'TUNL',
'TUNL-R' => 'TUNNEL',
'TUNNELS' => 'TUNL',
'TUNNL' => 'TUNL',
'UN' => 'UN',
'UNION' => 'UN',
'UN-R' => 'UNION',
'UNIONS' => 'UNS',
'UNS-R' => 'UNIONS',
'UNS' => 'UNS',
'UDRPS' => 'UPAS',
'UNDERPAS' => 'UPAS',
'UNDERPASS' => 'UPAS',
'UPAS-R' => 'UNDERPASS',
'UNDERPS' => 'UPAS',
'UNDRPAS' => 'UPAS',
'UNDRPS' => 'UPAS',
'UPAS' => 'UPAS',
'VDCT' => 'VIA',
'VIA' => 'VIA',
'VIADCT' => 'VIA',
'VIADUCT' => 'VIA',
'VIA-R' => 'VIADUCT',
'VIS' => 'VIS',
'VIST' => 'VIS',
'VISTA' => 'VIS',
'VIS-R' => 'VISTA',
'VST' => 'VIS',
'VSTA' => 'VIS',
'VILLE' => 'VL',
'VL-R' => 'VILLE',
'VL' => 'VL',
'VILG' => 'VLG',
'VILL' => 'VLG',
'VILLAG' => 'VLG',
'VILLAGE' => 'VLG',
'VLG-R' => 'VILLAGE',
'VILLG' => 'VLG',
'VILLIAGE' => 'VLG',
'VLG' => 'VLG',
'VILGS' => 'VLGS',
'VILLAGES' => 'VLGS',
'VLGS-R' => 'VILLAGES',
'VLGS' => 'VLGS',
'VALLEY' => 'VLY',
'VLY-R' => 'VALLEY',
'VALLY' => 'VLY',
'VALY' => 'VLY',
'VLLY' => 'VLY',
'VLY' => 'VLY',
'VALLEYS' => 'VLYS',
'VLYS-R' => 'VALLEYS',
'VLYS' => 'VLYS',
'VIEW' => 'VW',
'VW-R' => 'VIEW',
'VW' => 'VW',
'VIEWS' => 'VWS',
'VWS-R' => 'VIEWS',
'VWS' => 'VWS',
'WALK' => 'WALK',
'WALK-R' => 'WALK',
'WALKS' => 'WALK',
'WLK' => 'WALK',
'WALL' => 'WALL',
'WALL-R' => 'WALL',
'WAY' => 'WAY',
'WAY-R' => 'WAY',
'WY' => 'WAY',
'WAYS' => 'WAYS',
'WAYS-R' => 'WAYS',
'WEL' => 'WL',
'WELL' => 'WL',
'WL-R' => 'WELL',
'WL' => 'WL',
'WELLS' => 'WLS',
'WLS-R' => 'WELLS',
'WELS' => 'WLS',
'WLS' => 'WLS',
'CROSING' => 'XING',
'CROSNG' => 'XING',
'CROSSING' => 'XING',
'XING-R' => 'CROSSING',
'CRSING' => 'XING',
'CRSNG' => 'XING',
'CRSSING' => 'XING',
'CRSSNG' => 'XING',
'XING' => 'XING',
'CROSRD' => 'XRD',
'CROSSRD' => 'XRD',
'CROSSROAD' => 'XRD',
'XRD-R' => 'CROSSROAD',
'CRSRD' => 'XRD',
'XRD' => 'XRD',
'XROAD' => 'XRD',
);
}
/**
* Implement abbreviations for words at the ends of certain address lines.
*
* @param string $String the address fragments to be analyzed
* @return string the cleaned up string
*/
function ALS_EOL_Abbr($String) {
$Suff = 0;
$ID = 0;
$Parts = split(' ', $String);
$Count = count($Parts)-1;
for ($Counter = $Count; $Counter > -1; $Counter--) {
if (isset($this->Suffixes[$Parts[$Counter]])) {
if (!$Suff) {
$Out[$Counter] = $this->Suffixes[$Parts[$Counter]];
$Suff++;
if ($Counter == $Count) {
$ID = 1;
}
} else {
$Out[$Counter] = $Parts[$Counter];
}
} elseif (isset($this->Identifiers[$Parts[$Counter]])) {
$Out[$Counter] = $this->Identifiers[$Parts[$Counter]];
$ID = 1;
} elseif (isset($this->Directionals[$Parts[$Counter]])) {
$Out[$Counter] = $this->Directionals[$Parts[$Counter]];
if ($Counter == $Count) {
$ID = 1;
}
} else {
$Out[$Counter] = $Parts[$Counter];
}
}
ksort($Out);
return implode(' ', $Out);
}
/**
* Reformats a Delivery Address Line entered by a user to conform with
* the United States Postal Service's Addressing Standards.
*
*
This comes in VERY handy when searching for records by address.
* Let's say a data entry person put an address in as
* "Two N Boulevard." Later, someone else searches for them using
* "2 North Blvd." Unfortunately, that query won't find them. Such
* problems are averted by using this method before storing and
* searching for data.
*
*
Standardization can also help obtain lower bulk mailing rates.
*
*
Based upon USPS Publication 28, November 1997.
*
* @param string $Address the address to be converted
* @return string the cleaned up address
* @link http://pe.usps.gov/cpim/ftp/pubs/Pub28/pub28.pdf
*/
function AddressLineStandardization($Address) {
if (empty($Address)) {
return '';
}
$Address = ereg_replace('[#]', ' # ', $Address);
$Address = strtoupper(trim($Address));
$Address = ereg_replace('[^A-Z0-9[:space:]/#.-]', '', $Address);
$Address = ereg_replace('([A-Z])([.])', '\\1 ', $Address);
$Address = ereg_replace('([A-Z]+)([-])([A-Z]+)', '\\1 \\3', $Address);
$Address = ereg_replace('([^A-Z]+)([/.-]+)([^0-9]+)', '\\1\\3', $Address);
$Address = ereg_replace('([^0-9]+)([/.-]+)([^A-Z]+)', '\\1\\3', $Address);
$Address = ereg_replace('([[:space:]]+)', ' ', $Address);
if (ereg('(.+[[:space:]])([A-Z]+)([[:space:]][#])([[:space:]].+)', $Address, $Atom)) {
if (isset($this->Identifiers[$Atom[2]])) {
$Address = "$Atom[1]$Atom[2]$Atom[4]";
}
}
$Address = trim($Address);
$Parts = split(' ', $Address);
foreach ($Parts as $Key => $Val) {
if (isset($this->Numbers[$Val])) {
$Parts[$Key] = $this->Numbers[$Val];
}
}
$Address = implode(' ', $Parts);
unset($Parts);
$Address = ereg_replace('([0-9]+)(ST|ND|RD|TH)?([[:space:]]?)(FL|FLOOR|FLR)$', 'FL \\1', $Address);
$Address = ereg_replace('(NORTH|SOUTH)([[:space:]])(EAST|WEST)', '\\1\\3', $Address);
if (ereg('^(RR|RFD ROUTE|RURAL ROUTE|RURAL RT|RURAL RTE|RURAL DELIVERY|RD RTE|RD ROUTE)([[:space:]]?)([0-9]+)([A-Z #]+)([0-9A-Z]+)(.*)$', $Address, $Atom)) {
return "RR $Atom[3] BOX $Atom[5]";
}
if (ereg('^(BOX|BX)([ #]*)([0-9A-Z]+)([[:space:]])(RR|RFD ROUTE|RURAL ROUTE|RURAL RT|RURAL RTE|RURAL DELIVERY|RD RTE|RD ROUTE)([[:space:]]?)([0-9]+)(.*)$', $Address, $Atom)) {
return "RR $Atom[7] BOX $Atom[3]";
}
if (ereg('^(POST OFFICE BOX|PO BOX|P O|P O BOX|P O B|P O BX|POB|BOX|PO|PO BX|BX|FIRM CALLER|CALLER|BIN|LOCKBOX|DRAWER)([[:space:]]+([#][[:space:]])*)([0-9A-Z-]+)(.*)$', $Address, $Atom)) {
return "PO BOX $Atom[4]";
}
if (ereg('^([0-9A-Z.-]+[[:space:]]?[0-9/]*[[:space:]]?)(.*)( CNTY| COUNTY)([[:space:]])(HIGHWAY|HIGHWY|HIWAY|HIWY|HWAY|HWY)( NO | # | )?([0-9A-Z]+)(.*)$', $Address, $Atom)) {
if (isset($this->States[$Atom[2]])) {
$Atom[2] = $this->States[$Atom[2]];
}
if (isset($this->Identifiers[$Atom[7]])) {
$Atom[7] = $this->Identifiers[$Atom[7]];
$Atom[8] = ereg_replace(' #', '', $Atom[8]);
return "$Atom[1]$Atom[2] COUNTY HWY $Atom[7]$Atom[8]";
}
return "$Atom[1]$Atom[2] COUNTY HIGHWAY $Atom[7]" . $this->ALS_EOL_Abbr($Atom[8]);
}
if (ereg('^([0-9A-Z.-]+[[:space:]]?[0-9/]*[[:space:]]?)(.*)( CR |( CNTY| COUNTY)([[:space:]])(RD|ROAD))( NO | # | )?([0-9A-Z]+)(.*)$', $Address, $Atom)) {
if (isset($this->States[$Atom[2]])) {
$Atom[2] = $this->States[$Atom[2]];
}
if (isset($this->Identifiers["$Atom[8]"])) {
$Atom[8] = $this->Identifiers["$Atom[8]"];
$Atom[9] = ereg_replace(' #', '', $Atom[9]);
return "$Atom[1]$Atom[2] COUNTY RD $Atom[8]$Atom[9]";
}
return "$Atom[1]$Atom[2] COUNTY ROAD $Atom[8]" . $this->ALS_EOL_Abbr($Atom[9]);
}
if (ereg('^([0-9A-Z.-]+[[:space:]]?[0-9/]*[[:space:]]?)(.*)( SR|( ST| STATE)([[:space:]])(RD|ROAD))( NO | # | )?([0-9A-Z]+)(.*)$', $Address, $Atom)) {
if (isset($this->States[$Atom[2]])) {
$Atom[2] = $this->States[$Atom[2]];
}
if (isset($this->Identifiers["$Atom[8]"])) {
$Atom[8] = $this->Identifiers["$Atom[8]"];
$Atom[9] = ereg_replace(' #', '', $Atom[9]);
return "$Atom[1]$Atom[2] STATE RD $Atom[8]$Atom[9]";
}
return "$Atom[1]$Atom[2] STATE ROAD $Atom[8]" . $this->ALS_EOL_Abbr($Atom[9]);
}
if (ereg('^([0-9A-Z.-]+[[:space:]]?[0-9/]*[[:space:]]?)(.*)( ST| STATE)([[:space:]])(RT|RTE|ROUTE)( NO | # | )?([0-9A-Z]+)(.*)$', $Address, $Atom)) {
if (isset($this->States[$Atom[2]])) {
$Atom[2] = $this->States[$Atom[2]];
}
if (isset($this->Identifiers[$Atom[7]])) {
$Atom[7] = $this->Identifiers[$Atom[7]];
$Atom[8] = ereg_replace(' #', '', $Atom[8]);
return "$Atom[1]$Atom[2] STATE RTE $Atom[7]$Atom[8]";
}
return "$Atom[1]$Atom[2] STATE ROUTE $Atom[7]" . $this->ALS_EOL_Abbr($Atom[8]);
}
if (ereg('^([0-9A-Z.-]+[[:space:]][0-9/]*[[:space:]]?)(I|INTERSTATE|INTRST|INT)([[:space:]]?)(HIGHWAY|HIGHWY|HIWAY|HIWY|HWAY|HWY|H)?([[:space:]]?)([0-9]+)(.*)$', $Address, $Atom)) {
$Atom[7] = ereg_replace(' BYP ', ' BYPASS ', $Atom[7]);
return "$Atom[1]INTERSTATE $Atom[6]" . $this->ALS_EOL_Abbr($Atom[7]);
}
if (ereg('^([0-9A-Z.-]+[[:space:]]?[0-9/]*[[:space:]]?)(.*)( ST| STATE)([[:space:]])(HIGHWAY|HIGHWY|HIWAY|HIWY|HWAY|HWY)( NO | # | )?([0-9A-Z]+)(.*)$', $Address, $Atom)) {
if (isset($this->States[$Atom[2]])) {
$Atom[2] = $this->States[$Atom[2]];
}
if (isset($this->Identifiers[$Atom[7]])) {
$Atom[7] = $this->Identifiers[$Atom[7]];
$Atom[8] = ereg_replace(' #', '', $Atom[8]);
return "$Atom[1]$Atom[2] STATE HWY $Atom[7]$Atom[8]";
}
return "$Atom[1]$Atom[2] STATE HIGHWAY $Atom[7]" . $this->ALS_EOL_Abbr($Atom[8]);
}
if (ereg('^([0-9A-Z.-]+[[:space:]]?[0-9/]*[[:space:]]?)(.*)( US| U S|UNITED STATES)([[:space:]])(HIGHWAY|HIGHWY|HIWAY|HIWY|HWAY|HWY)( NO | # | )?([0-9A-Z]+)(.*)$', $Address, $Atom)) {
if (isset($this->States[$Atom[2]])) {
$Atom[2] = $this->States[$Atom[2]];
}
if (isset($this->Identifiers[$Atom[7]])) {
$Atom[7] = $this->Identifiers[$Atom[7]];
$Atom[8] = ereg_replace(' #', '', $Atom[8]);
return "$Atom[1]$Atom[2] US HWY $Atom[7]$Atom[8]";
}
return "$Atom[1]$Atom[2] US HIGHWAY $Atom[7]" . $this->ALS_EOL_Abbr($Atom[8]);
}
if (ereg('^([0-9A-Z.-]+[[:space:]][0-9/]*[[:space:]]?)(RANCH )(RD|ROAD)( NO | # | )?([0-9A-Z]+)(.*)$', $Address, $Atom)) {
if (isset($this->Identifiers["$Atom[5]"])) {
$Atom[5] = $this->Identifiers["$Atom[5]"];
$Atom[6] = ereg_replace(' #', '', $Atom[6]);
return "$Atom[1]RANCH RD $Atom[5]$Atom[6]";
}
return "$Atom[1]RANCH ROAD $Atom[5]" . $this->ALS_EOL_Abbr($Atom[6]);
}
$Address = ereg_replace('^([0-9A-Z.-]+)([[:space:]])([0-9][/][0-9])', '\\1*\\3', $Address);
if (ereg('^([0-9A-Z/*.-]+[[:space:]])(RD|ROAD)([A-Z #]+)([0-9A-Z]+)(.*)$', $Address, $Atom)) {
$Atom[1] = ereg_replace('[*]', ' ', $Atom[1]);
return "$Atom[1]ROAD $Atom[4]" . $this->ALS_EOL_Abbr($Atom[5]);
}
if (ereg('^([0-9A-Z/*.-]+[[:space:]])(RT|RTE|ROUTE)([A-Z #]+)([0-9A-Z]+)(.*)$', $Address, $Atom)) {
$Atom[1] = ereg_replace('[*]', ' ', $Atom[1]);
return "$Atom[1]ROUTE $Atom[4]" . $this->ALS_EOL_Abbr($Atom[5]);
}
if (ereg('^([0-9A-Z/*.-]+[[:space:]])(AV|AVE|AVEN|AVENU|AVENUE|AVN|AVNUE)([[:space:]])([A-Z]+)(.*)$', $Address, $Atom)) {
$Atom[1] = ereg_replace('[*]', ' ', $Atom[1]);
return "$Atom[1]AVENUE $Atom[4]" . $this->ALS_EOL_Abbr($Atom[5]);
}
if (ereg('^([0-9A-Z/*.-]+[[:space:]])(BLVD|BOUL|BOULEVARD|BOULV)([[:space:]])([A-Z]+)(.*)$', $Address, $Atom)) {
$Atom[1] = ereg_replace('[*]', ' ', $Atom[1]);
return "$Atom[1]BOULEVARD " . $this->ALS_EOL_Abbr("$Atom[4]$Atom[5]");
}
$Address = ereg_replace('^([0-9A-Z/*.-]+[[:space:]])(ST )', '\\1SAINT ', $Address);
$Parts = split(' ', $Address);
$Count = count($Parts)-1;
$Suff = 0;
$ID = 0;
for ($Counter = $Count; $Counter > -1; $Counter--) {
if (isset($this->Suffixes[$Parts[$Counter]])) {
if (!$Suff) {
if (!empty($Out[$Counter+1]) AND !empty($Out[$Counter+2])) {
switch ($Out[$Counter+1] . ' ' .$Out[$Counter+2]) {
case 'EAST W':
case 'WEST E':
case 'NORTH S':
case 'SOUTH N':
$Out[$Counter] = $Parts[$Counter];
break;
default:
$Out[$Counter] = $this->Suffixes[$Parts[$Counter]];
}# End of SWITCH next 2.
} else {
$Out[$Counter] = $this->Suffixes[$Parts[$Counter]];
}
if ($Counter == $Count) {
$ID++;
}
} else {
switch ($Parts[$Counter]) {
case 'VIA':
case 'LA':
$Out[$Counter] = $Parts[$Counter];
break;
default:
$Out[$Counter] = $this->Suffixes[$Parts[$Counter]];
$Out[$Counter] = $this->Suffixes["$Out[$Counter]-R"];
}
}# End of IF stop under suffixes.
$Suff++;
} elseif (isset($this->Identifiers[$Parts[$Counter]])) {
$Out[$Counter] = $this->Identifiers[$Parts[$Counter]];
if ($Suff > 0) {
$Out[$Counter] = $this->Identifiers["$Out[$Counter]-R"];
}
$ID++;
} elseif (isset($this->Directionals[$Parts[$Counter]])) {
$Prior = $Counter - 1;
$Next = $Counter + 1;
if (!empty($Parts[$Next]) AND isset($this->Suffixes[$Parts[$Next]])) {
$Out[$Counter] = $this->Directionals[$Parts[$Counter]];
if ($Suff <= 1) {
$Out[$Counter] = $this->Directionals["$Out[$Counter]-R"];
}
} elseif ($Counter > 2 AND !empty($Parts[$Next]) AND isset($this->Directionals[$Parts[$Next]])) {
$Out[$Counter] = $Parts[$Counter];
} elseif ($Counter == 2 AND isset($this->Directionals[$Parts[$Prior]])) {
$Out[$Counter] = $Parts[$Counter];
} else {
$Out[$Counter] = $this->Directionals[$Parts[$Counter]];
}# End of IF ELSEIF under directionals
if ($Counter == $Count) {
$ID = 1;
}
} elseif (ereg('(^([0-9]*)$)', $Parts[$Counter])
&& $Counter > 0
&& $Counter < $Count)
{
$Prior = $Counter - 1;
$Next = $Counter + 1;
if (isset($this->Directionals[$Parts[$Prior]])
&& isset($this->Directionals[$Parts[$Next]]))
{
$Out[$Counter] = $Parts[$Counter];
} else {
switch (substr($Parts[$Counter],-2)) {
case 11:
case 12:
case 13:
$Out[$Counter] = $Parts[$Counter] . 'TH';
break;
default:
switch (substr($Parts[$Counter],-1)) {
case 1:
$Out[$Counter] = $Parts[$Counter] . 'ST';
break;
case 2:
$Out[$Counter] = $Parts[$Counter] . 'ND';
break;
case 3:
$Out[$Counter] = $Parts[$Counter] . 'RD';
break;
default:
$Out[$Counter] = $Parts[$Counter] . 'TH';
}# End of SWITCH substr -1 $Temp
}# End of SWITCH substr -2 $Temp
}# End of IF prior and next are directionals under numbers.
} else {
$Out[$Counter] = $Parts[$Counter];
}# End of IF ELSEIF for current part.
}# End of FOR parts counter.
$Out[0] = ereg_replace('[*]', ' ', $Out[0]);
ksort($Out);
return implode(' ', $Out);
}
/**
* Generates a XHTML option list of states.
*
* @param mixed $Default string or array of values to be selected
* @param string $Name the name attribute for the form element
* @param string $Visible what users see in the list:
* Word (names)
* or Abbr (initials)
* @param string $Value values for the options:
* Word (names)
* or Abbr (initials)
* @param string $Class class attribute for the
\n\n";
}
}