Revision: 38036
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 23, 2010 01:54 by iloveitaly
Initial Code
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.
(empty($this->city) || empty($this->providence) ? ' '.$this->country : '');
} 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') {
return trim(trim($this->address1."\n".$this->address2)."\n".$this->city).", ".$this->providence." ".$this->postal_code;
} else {
return trim(trim($this->address1."\n".$this->address2)."\n".$this->city).", ".$this->providence." ".$this->postal_code." ".$this->country;
}
}
Initial URL
Initial Description
I'm not well versed in international address formatting, but this seems to work for most cases. Critiques are welcome!
Initial Title
International Short & Long Address Formatting
Initial Tags
php
Initial Language
PHP