glagola/cross-product-iterator
Composer 安装命令:
composer require glagola/cross-product-iterator
包简介
Cross product of unlimited arrays without any recursion
README 文档
README
Required php version at least 5.1
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require "glagola/cross-product-iterator" "*"
or add
"glagola/cross-product-iterator" : "*"
to the require section of your application's composer.json file.
Example
Code
<?php use Glagola\CrossProductIterator; function aa() { yield 'x1'; yield 'x2'; yield 'x3'; } $iterator = new CrossProductIterator([ aa(), new ArrayIterator(['y1']), new ArrayIterator(['z1', 'z2', 'z3']), new ArrayIterator(['f1', 'f2', 'f3']), ]); foreach ($iterator as $items) { echo "['", implode("', '", $items), "']", PHP_EOL; }
Output
['x1', 'y1', 'z1', 'f1']
['x1', 'y1', 'z1', 'f2']
['x1', 'y1', 'z1', 'f3']
['x1', 'y1', 'z2', 'f1']
['x1', 'y1', 'z2', 'f2']
['x1', 'y1', 'z2', 'f3']
['x1', 'y1', 'z3', 'f1']
['x1', 'y1', 'z3', 'f2']
['x1', 'y1', 'z3', 'f3']
['x2', 'y1', 'z1', 'f1']
['x2', 'y1', 'z1', 'f2']
['x2', 'y1', 'z1', 'f3']
['x2', 'y1', 'z2', 'f1']
['x2', 'y1', 'z2', 'f2']
['x2', 'y1', 'z2', 'f3']
['x2', 'y1', 'z3', 'f1']
['x2', 'y1', 'z3', 'f2']
['x2', 'y1', 'z3', 'f3']
['x3', 'y1', 'z1', 'f1']
['x3', 'y1', 'z1', 'f2']
['x3', 'y1', 'z1', 'f3']
['x3', 'y1', 'z2', 'f1']
['x3', 'y1', 'z2', 'f2']
['x3', 'y1', 'z2', 'f3']
['x3', 'y1', 'z3', 'f1']
['x3', 'y1', 'z3', 'f2']
['x3', 'y1', 'z3', 'f3']
统计信息
- 总下载量: 33
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-01-16