adamhebby / php-scrollable-selection
PHP 可滚动用户选择列表
v1.0.3
2018-10-30 21:29 UTC
This package is auto-updated.
Last update: 2024-08-29 04:59:43 UTC
README
允许用户从可滚动列表中选择一个选项,返回从原始数组输入中选择的键
循环模式
单列表模式
自定义颜色和光标文本
可用颜色
安装
composer require adamhebby/php-scrollable-selection
示例
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"; }