elminson/permutations
最新稳定版本:v1.0.1
Composer 安装命令:
composer require elminson/permutations
包简介
The Permutations generator package
README 文档
README
A convenient way to generate permutations of arrays.
Ex.
// Customizable features for a smartphone $colors = ['Black', 'White']; $storageCapacities = ['64GB', '128GB']; // Generating variations using Permutations::generate $actualVariations = Permutations::generate([$colors, $storageCapacities]);
Result
Array
(
[0] => Array
(
[0] => Black
[1] => 64GB
)
[1] => Array
(
[0] => Black
[1] => 128GB
)
[2] => Array
(
[0] => White
[1] => 64GB
)
[3] => Array
(
[0] => White
[1] => 128GB
)
)
You can also include the original array by doing
$includeOriginalArray = true; $array = ['AB', 'CD']; $array1 = ['EF', 'GH']; $permutationsExpected = [ ['AB', 'CD'], ['EF', 'GH'], ['AB', 'EF'], ['AB', 'GH'], ['CD', 'EF'], ['CD', 'GH']]; $permutationsElements = Arr::permutations([$array, $array1], $includeOriginalArray);
Result
Array
(
[0] => Array
(
[0] => AB
[1] => CD
)
[1] => Array
(
[0] => EF
[1] => GH
)
[2] => Array
(
[0] => AB
[1] => EF
)
[3] => Array
(
[0] => AB
[1] => GH
)
[4] => Array
(
[0] => CD
[1] => EF
)
[5] => Array
(
[0] => CD
[1] => GH
)
)
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-12-02