else { $extraOutput = '[' .
$extraOutputDefault . ', ' .
implode(', ',
$opts) . ']';
$validation[] = 'in_list[' .
implode(', ',
$options) . ']';
} $default =
$options[0
];
} static::
fwrite(STDOUT,
$field .
(trim($field) ? ' ' : ''
) .
$extraOutput . ': '
);
// Read the input from keyboard.
$input =
trim(static::
input()) ?:
$default;
if ($validation) { while (!
static::
validate(trim($field),
$input,
$validation)) { $input =
static::
prompt($field,
$options,
$validation);
} } return $input;
} /**
* prompt(), but based on the option's key
*
* @param array|string $text Output "field" text or an one or two value array where the first value is the text before listing the options
* and the second value the text before asking to select one option. Provide empty string to omit
* @param array $options A list of options (array(key => description)), the first option will be the default value
* @param array|string|null $validation Validation rules
*
* @return string The selected key of $options
*
* @codeCoverageIgnore
*/