Search code examples
phpperlstreet-address

Formatting a Shipping Address by Country in PHP (or Perl)


I have an HTML form that takes an input shipping address in parts (street address, city, state/province, postal code, and country). This form is then processed with PHP.

I'd like to convert this address into the correct format for the destination country. Are there any libraries or external services that I could use to do this conversion in PHP? If not, could I do it with Perl or a similar language?


Solution

  • For anyone still looking for a solution, there is now a professional made, well maintained open source library https://github.com/commerceguys/addressing that solves this exact problem.