I have an array of menus (breakfast, lunch, dinner) with their start times (08:00:00, 11:00:00, 16:00:00), and I need to pull out the menu closest to now() in the future and know which menu it is. This is what I have:
$menus = array(
array("breakfast", "08:00:00"),
array("lunch", "11:00:00"),
array("dinner", "16:00:00")
);
This is how I've been getting the soonest menu (assuming it's before 8am).
foreach($menus as $a) {
$menu[] = $a[0];
$time[] = $a[1];
}
echo min($time);
This gets me the soonest time 08:00:00
, but I can't figure out how to attach the menu to this realization. Let's say it echoes 08:00:00
, how can I get the $menu
in there so I can also know that 08:00:00
corresponds to "breakfast"
?