adamhebby/php-scrollable-selection

PHP Scrollable user selection list

v1.0.3 2018-10-30 21:29 UTC

This package is auto-updated.

Last update: 2024-10-29 05:34:22 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

Allows a user to select an option from a scrollable list, returns key selected from original array input

Loop Mode

Single List Mode

Custom Colors & Cursor Text

Available Colors

Installation

composer require adamhebby/php-scrollable-selection

Example

require __DIR__ . '/vendor/autoload.php';
use AdamHebby\ScrollableSelection;

$list = array();

for ($i=1; $i < 50; $i++) {
    $list[] = "$i " . str_repeat('-', 20);
}

$ScrollableSelection = new ScrollableSelection(
    [
        'list'     => $list,
        'maxItems' => 10,
        'loops'    => true,
        'startKey' => 0,
        'cursor'   => '>',
        'colors'   => [
            'active'   => 'white',
            'inactive' => 'dark_gray'
        ]
    ]
);

$key = $ScrollableSelection->displayList();

if (!isset($list[$key])) {
    echo "User quit selection \n\n";
} else {
    echo "\nUser selected {$list[$key]} \n\n";
}