Skip to content

Instantly share code, notes, and snippets.

@Ryokuchaneko
Last active December 19, 2015 17:39
Show Gist options
  • Save Ryokuchaneko/5993195 to your computer and use it in GitHub Desktop.
Save Ryokuchaneko/5993195 to your computer and use it in GitHub Desktop.
$people = array(array('Symour', 'BOS'), array('Franny', 'DAL'), array('Zooey', 'CAK'), array('Walt', 'MIA'), array('Buddy', 'ORD'), array('Les', 'OMA'));
$destination = 'LGA';
$flights = array();
$fp = fopen("schedule.txt", "r");
while($line = fgets($fp)) {
$line = rtrim($line);
$explode_line = explode(",",$line);
$origin = $explode_line[0];
$dest = $explode_line[1];
$depart = $explode_line[2];
$arrive = $explode_line[3];
$price = $explode_line[4];
if(!isset($flights[$origin][$dest])){
$flights[$origin][$dest] = array();
}
$flights[$origin][$dest][] = array($depart, $arrive, $price);
}
function getminutes($t) {
$x = strptime($t, '%H:%M');
return $x["tm_min"] + $x["tm_hour"]*60;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment