khartnett/address-normalization

将邮寄地址转换为标准化格式

1.0.0 2017-12-14 21:59 UTC

This package is not auto-updated.

Last update: 2024-09-14 17:48:12 UTC


README

目的

一种无需外部服务即可标准化美国邮寄地址的方法。这是由Schuyler D. Erle最初编写的perl模块Geo::StreetAddress::US的移植版本。

安装

$composer require khartnett/address-normalization

用法

<?php
 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"
  */