Advertisement
einpraegsam

Coordinates from ZIP Code

Aug 29th, 2011
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.79 KB | None | 0 0
  1. /**
  2.  * Get latitude and longitude from german ZIP Code
  3.  *
  4.  * @param   string      URL for geocode table
  5.  * @return  array       Array with Latitude and Longitude and the Cities Name like
  6.  *                      01067 =>
  7.  *                          lat => 1.12351
  8.  *                          lng => 45.4541
  9.  *                          title => Dresden
  10.  */
  11. public function getCoordinatesFromZip($geocodeurl = 'http://fa-technik.adfc.de/code/opengeodb/PLZ.tab') {
  12.     $arr = array();
  13.     $table = t3lib_div::getUrl($geocodeurl); // read url
  14.     $lines = t3lib_div::trimExplode("\n", $table, 1); // split every line
  15.     for ($i = 0; $i < count($lines); $i++) { // one loop for every line
  16.         $line = explode("\t", $lines[$i]);
  17.         $arr[$line[1]] = array (
  18.             'title' => $line[4], // Name of the City
  19.             'lng' => $line[2], // Latitude
  20.             'lat' => $line[3] // Longitude
  21.         );
  22.     }
  23.    
  24.     return $arr;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement