You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
527 B

<?php
namespace p3k;
class Airports {
private static $fp = false;
public static function from_code($code) {
if(!self::$fp) {
$fp = fopen(__DIR__.'/../data/airports-compact.csv', 'r');
}
rewind($fp);
$airport = false;
while(!$airport && ($line=fgetcsv($fp))) {
if($line[0] == $code) {
$airport = [
'code' => $code,
'latitude' => $line[1],
'longitude' => $line[2],
'name' => $line[3],
];
}
}
return $airport;
}
}