/ Published in: PHP
I'm not well versed in international address formatting, but this seems to work for most cases. Critiques are welcome!
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
if($key == 'short_address') { // this is tricky b/c of international addresses // if the location is US based then we want to display an identifier similiar to: Bob's Place in Downingtown OH // if the location is non-USA based (and either city or providence is not available) then we want to display: Bob's Place in Downingtown USA return $this->name.' in '.$this->city.' '.$this->providence. } else if($key == 'full_address') { // target format for US based addresses: // 300 Road Street // Town PA, 19335 // target format for non-US based addresses // address1 // City, Providence Postal Code Country // the trims handle edge cases when there is not enough information to propertly display an address if($this->country == 'US') { } else { } }