Posted By

iloveitaly on 12/19/10


Tagged

object array generate address


Versions (?)

Generate Address String from Array / Object


 / Published in: PHP
 

Useful when used with the google map directions function http://snipplr.com/view/15530/php-create-google-map-directions-link/

  1. function getAddress($dbObject) {
  2. $keys = array('address1', 'city', 'providence', 'postal_code');
  3. $values = array();
  4.  
  5. foreach($keys as $key)
  6. if(!empty($dbObject->$key))
  7. $values[] = $dbObject->$key;
  8.  
  9. return implode(' ', $values);
  10. }

Report this snippet  

You need to login to post a comment.