All Projects → adamlc → address-format

adamlc / address-format

Licence: MIT license
A PHP library to parse street addresses to localized formats

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to address-format

street-address
Street address parser and formatter
Stars: ✭ 86 (+13.16%)
Mutual labels:  formatter, street-address
TcBlack
Opnionated code formatter for TwinCAT.
Stars: ✭ 67 (-11.84%)
Mutual labels:  formatter
Sublime-uroboroSQL-formatter
Beautiful SQL Formatter for Sublime Text 3
Stars: ✭ 25 (-67.11%)
Mutual labels:  formatter
rust-phonenumber
Library for parsing, formatting and validating international phone numbers.
Stars: ✭ 99 (+30.26%)
Mutual labels:  formatter
blackbricks
Black for Databricks notebooks
Stars: ✭ 40 (-47.37%)
Mutual labels:  formatter
awesome-python-code-formatters
A curated list of awesome Python code formatters
Stars: ✭ 168 (+121.05%)
Mutual labels:  formatter
Mbeautifier
MBeautifier is a MATLAB source code formatter, beautifier. It can be used directly in the MATLAB Editor and it is configurable.
Stars: ✭ 248 (+226.32%)
Mutual labels:  formatter
ByteSizeLibPascal
TByteSize is a utility record that makes byte size representation in code easier by removing ambiguity of the value being represented.
Stars: ✭ 24 (-68.42%)
Mutual labels:  formatter
uck
숫자 -> 한글 단위 변환 모듈
Stars: ✭ 27 (-64.47%)
Mutual labels:  formatter
sql-formatter
Polyglot SQL formatter
Stars: ✭ 28 (-63.16%)
Mutual labels:  formatter
lit-date
Light-weight, faster datetime formatter for modern browsers.
Stars: ✭ 33 (-56.58%)
Mutual labels:  formatter
fixjson
JSON Fixer for Humans using (relaxed) JSON5
Stars: ✭ 96 (+26.32%)
Mutual labels:  formatter
vscode-qiniu-upload-image
一个VS Code插件,写Markdown时可以快捷上传本地图片获取七牛图床外链。
Stars: ✭ 87 (+14.47%)
Mutual labels:  formatter
idea-uroborosql-formatter
Beautiful SQL Formatter for IntelliJ Platform
Stars: ✭ 18 (-76.32%)
Mutual labels:  formatter
json-lua
JSON encoder/decoder
Stars: ✭ 47 (-38.16%)
Mutual labels:  formatter
Best Of Python Dev
🏆 A ranked list of awesome python developer tools and libraries. Updated weekly.
Stars: ✭ 243 (+219.74%)
Mutual labels:  formatter
palantir-java-format
A modern, lambda-friendly, 120 character Java formatter.
Stars: ✭ 203 (+167.11%)
Mutual labels:  formatter
ISO8601
🎗 Super lightweight ISO8601 Date Formatter in Swift
Stars: ✭ 20 (-73.68%)
Mutual labels:  formatter
format-imports-vscode
Format imports and exports for JavaScript and TypeScript in VS Code.
Stars: ✭ 60 (-21.05%)
Mutual labels:  formatter
winston-dev-console
Winston@3 console format aimed to improve development UX
Stars: ✭ 88 (+15.79%)
Mutual labels:  formatter

Address Format

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads

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

I have written a few basic unit tests, but they could probably be improved. Feel free to submit a pull request if you improve them!

Composer

To install AddressFormat as a Composer package add this to your composer.json:

"adamlc/address-format": "~1.3"

Run composer update

Formatting a Street Address

//Create an address formatter instance
$address_formatter = new Adamlc\AddressFormat\Format;

//Set a locale using a two digit ISO country code.
$address_formatter->setLocale('GB');

//Set the address parts / attributes
$address_formatter['ADMIN_AREA'] = 'London';
$address_formatter['LOCALITY'] = 'Greenwich';
$address_formatter['RECIPIENT'] = 'Joe Bloggs';
$address_formatter['ORGANIZATION'] = 'Novotel London';
$address_formatter['POSTAL_CODE'] = 'SE10 8JA';
$address_formatter['STREET_ADDRESS'] = '173-185 Greenwich High Road';
$address_formatter['COUNTRY'] = 'United Kingdom';

//Get the address in localised format
$html = true; // Optional - return the address in HTML <br> instead of \n new lines

echo $address_formatter->formatAddress($html);

The above code will produce the following:

Joe Bloggs
Novotel London
173-185 Greenwich High Road
Greenwich
London
SE10 8JA

Note: Look in the i18n directory to view the meta data for the locales.

The following attributes are available:

ADMIN_AREA
LOCALITY
RECIPIENT
ORGANIZATION
DEPENDENT_LOCALITY
POSTAL_CODE
SORTING_CODE
STREET_ADDRESS
COUNTRY

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].