$v) { $identifiers[strtolower($v['identifier'])] = $k; $max_length = max(strlen($v['identifier']), $max_length); } while (true) { if ($clear) { self::ClearScreen(); } echo "Please select one of the following options:\n\n"; // Print the menu foreach ($items as $k => $v) { echo str_pad($v['identifier'], $max_length, ' ', STR_PAD_LEFT), ") ", $v['text'], "\n"; } echo "\nSelect: "; $input = trim(strtolower(self::GetLine())); // Invalid menu item chosen if (!isset($identifiers[$input])) { echo "Invalid menu item chosen...\n"; sleep(1); continue; // Valid menu item chosen } else { $item = $items[$identifiers[$input]]; if (!empty($item['callback']) AND is_callable($item['callback'])) { call_user_func($item['callback'], $input); } return $input; } } } } ?>