示例#1
0
function ask_y_or_n($question)
{
    echo "{$question} (y or n): ";
    $input_str = my_fgets();
    echo "\n";
    if ($input_str === "y") {
        return true;
    } else {
        if ($input_str === "n") {
            return false;
        } else {
            echo "Your input is invalid.\n";
            exit(1);
        }
    }
}
示例#2
0
function select_snt()
{
    $snts = get_schedule();
    foreach ($snts as $key => $snt) {
        echo "{$key}) " . date('Y-m-d H:i', time_of_when($snt["when"])) . "\n";
    }
    echo "\n";
    echo "Select a S&T (x to exit): ";
    $input_str = my_fgets();
    echo "\n";
    if ($input_str === "x") {
        echo "Exit\n";
        exit(0);
    } else {
        if (my_key_exists($input_str, $snts)) {
            $snt = $snts[(int) $input_str];
            echo "The S&T on " . date('Y-m-d H:i', time_of_when($snt["when"])) . " is selected.\n\n";
            return $snt;
        } else {
            echo "Your input is invalid.\n";
            exit(1);
        }
    }
}