address format
1.5.0
ไลบรารี PHP เพื่อแยกวิเคราะห์ที่อยู่เป็นรูปแบบที่แปลเป็นภาษาท้องถิ่น address format จะขึ้นอยู่กับรูปแบบที่จัดทำโดย libaddressinput ของ Google
ฉันได้เขียนการทดสอบหน่วยขั้นพื้นฐานบางอย่างแล้ว แต่อาจมีการปรับปรุงได้ อย่าลังเลที่จะส่งคำขอดึงหากคุณปรับปรุง!
หากต้องการติดตั้ง AddressFormat เป็นแพ็คเกจ Composer ให้เพิ่มสิ่งนี้ใน composer.json ของคุณ:
"adamlc/address-format" : " ~1.3 "
เรียกใช้ composer update
//Create an address format ter 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 );
รหัสข้างต้นจะสร้างสิ่งต่อไปนี้:
Joe Bloggs
Novotel London
173-185 Greenwich High Road
Greenwich
London
SE10 8JA
หมายเหตุ: ดูในไดเร็กทอรี i18n เพื่อดูข้อมูลเมตาสำหรับโลแคล
มีแอตทริบิวต์ต่อไปนี้:
ADMIN_AREA
ท้องถิ่น
ผู้รับ
องค์กร
DEPENDENT_LOCALITY
POSTAL_CODE
การเรียงลำดับ_รหัส
STREET_ADDRESS
ประเทศ