torann/address-format 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

torann/address-format

最新稳定版本:2.0.0

Composer 安装命令:

composer require torann/address-format

包简介

A PHP library to parse street addresses to localized formats

README 文档

README

Build Status Latest Stable Version Total Downloads Patreon donate button Donate weekly to this project using Gratipay Donate to this project using Flattr Donate to this project using Paypal

A PHP library to parse street addresses to localized formats. The address formats are based on the formats supplied by Google's libaddressinput.

Installation

Composer

From the command line run:

$ composer require torann/address-format

Usage

Formatting

format(array $data, $html = false)

Arguments:

  • $data - An array of address elements
  • $html - When set to true the address elements will be wrapped with span tags.

NOTE: The wrapping span tags contain itemprop attributes that adhere to the PostalAddress schema.

Usage:

$address = \Torann\AddressFormat\Address::format([
    'recipient' => 'Jane Doe',
    'organization' => 'Whitworth Institute Inc.',
    'street_address' => '20341 Whitworth Institute',
    'street_address_2' => '405 N. Whitworth',
    'locality' => 'Seattle',
    'admin_area' => 'WA',
    'postal_code' => '98052',
    'country_iso' => 'US',
]);

The above code will produce the following:

Jane Doe
Whitworth Institute Inc.
20341 Whitworth Institute
405 N. Whitworth
Seattle, WA 98052

NOTE: The country_iso attribute is used to determine the address's format. The default is set to US.

Custom Country Formats

This allows you to set your own formats.

setFormats(array $countries)

Arguments:

  • $countries - An array of country ISO codes and corresponding formats values.

Usage:

\Torann\AddressFormat\Address::setFormats([
    'GB' => '%N%n%O%n%A%n%C%n%Z %R',
    'US' => '%N%n%O%n%A%n%C, %S %Z %R',
]);

Available Attributes

Attribute Format Key Common Name
admin_area S state
locality C city
recipient N person's name
organization O organization
dependent_locality D
postal_code Z zip code
sorting_code X
street_address A
country R

Change Log

v1.0.0

  • First release

统计信息

  • 总下载量: 4.8k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-2-Clause
  • 更新时间: 2016-10-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固