core/classes/Console.class.php
public static function consoleQuestion($question,$options){

        @ob_flush();

        $orgQuestion = $question;

        $opts = '';

        foreach($options as $value => $statement){
            $opts .= "'{$value}') echo '{$value}'; break;;";
            $question .= PHP_EOL . "($value) - {$statement}";
        }//foreach

        $question .= PHP_EOL . 'Your answer? : ';

        exec("
        while true; do
            read -p '{$question}' answer 
            case \$answer in
                {$opts}
                *) echo ''; break;;
            esac
        done
            ",
            $answer
        );

        if(!array_key_exists($answer[0],$options)){
            echo PHP_EOL . 'Please enter a valid option and try again!' . PHP_EOL . PHP_EOL;
            return self::consoleQuestion($orgQuestion,$options);
        }//if
    
        return $answer[0];

    }
public static function consoleQuestion($question,$options){

        @ob_flush();

        $orgQuestion = $question;

        $opts = '';

        foreach($options as $value => $statement){
            $opts .= "'{$value}') echo '{$value}'; break;;";
            $question .= PHP_EOL . "($value) - {$statement}";
        }//foreach

        $question .= PHP_EOL . 'Your answer? : ';

        exec("
        while true; do
            read -p '{$question}' answer 
            case \$answer in
                {$opts}
                *) echo ''; break;;
            esac
        done
            ",
            $answer
        );

        if(!array_key_exists($answer[0],$options)){
            echo PHP_EOL . 'Please enter a valid option and try again!' . PHP_EOL . PHP_EOL;
            return self::consoleQuestion($orgQuestion,$options);
        }//if
    
        return $answer[0];

    }
public static function consoleQuestion ( $ question , $ options ) { @ ob_flush ( ) ; $ orgQuestion = $ question ; $ opts = '' ; foreach ( $ options as $ value => $ statement ) { $ opts .= "'{$value}') echo '{$value}'; break;;" ; $ question .= PHP_EOL . "($value) - {$statement}" ; } //foreach $ question .= PHP_EOL . 'Your answer? : ' ; exec ( "
        while true; do
            read -p '{$question}' answer 
            case \$answer in
                {$opts}
                *) echo ''; break;;
            esac
        done
            " , $ answer ) ; if ( ! array_key_exists ( $ answer [ 0 ] , $ options ) ) { echo PHP_EOL . 'Please enter a valid option and try again!' . PHP_EOL . PHP_EOL ; return self :: consoleQuestion ( $ orgQuestion , $ options ) ; } //if return $ answer [ 0 ] ; }
Prompt the user at the console with a question and the valid options that serve as an answer to that
question.

@param string $question The question being asked.
@param array $options The possible answers to the question being asked, where the keys are the anwsers and
the values are the description of the answer.

@return mixed The selected key from $options param.
Prompt the user at the console with a question and the valid options that serve as an answer to that question .