jefhar/fisher-yates
最新稳定版本:1.0.1
Composer 安装命令:
composer require jefhar/fisher-yates
包简介
A PHP implementation of the Fisher-Yates shuffle
README 文档
README
A PHP implementation of the Fisher-Yates shuffle with a deterministic shuffle.
Installing
This requires a minimum version of PHP 8.2.
Use Composer:
composer require jefhar/fisher-yates
Usage
use Lmc\FisherYates\FisherYates; $itemsToShuffle = ['a', 'b', 'c', 'd', 'e']; $fy = new FisherYates($itemsToShuffle); $result = $fy->shuffle();
If you need a deterministic shuffle, you can send a seed to the shuffle method:
use Lmc\FisherYates\FisherYates; $seed = 123_456_789; $itemsToShuffle = ['a', 'b', 'c', 'd', 'e']; $fy = new FisherYates($itemsToShuffle); var_dump($fy->shuffle($seed));
array(5) { [0]=> string(1) "d" [1]=> string(1) "a" [2]=> string(1) "b" [3]=> string(1) "e" [4]=> string(1) "c" }
统计信息
- 总下载量: 12
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-09