jelle-s/arraykeycombiner
Composer 安装命令:
composer require jelle-s/arraykeycombiner
包简介
Combines arrays by searching for intersections and adding them to the master array. Keys are combined using a delimiter.
README 文档
README
Combines arrays by searching for intersections and adding them to the master array. Keys are combined using a delimiter.
use Jelle_S\Util\Combiner\ArrayKeyCombiner; // Search this array of arrays for intersections and extract them, using a // delimiter to combine the keys. Limit the number of iterations to search for // intersections to 10.000, limit the minimum size of intersections to 3, set // the key delimiter to a comma. $arrays = array( array( 'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 9, ), array( 'a' => 1, 'b' => 2, 'c' => 3, 'e' => 9, ), array( 'a' => 1, 'b' => 42, 'c' => 3, 'd' => 4, ), array( 'b' => 42, 'c' => 3, 'a' => 1, ), array( 'z' => 26, 'e' => 9, 'a' => 1, ), ); $combiner = new Jelle_S\Util\Combiner\ArrayKeyCombiner($arrays, 3, 10000, ','); print_r($combiner->combine());
Output:
Array
(
[4] => Array
(
[a] => 1
[e] => 9
[z] => 26
)
[0,1] => Array
(
[a] => 1
[b] => 2
[c] => 3
[e] => 9
)
[2,3] => Array
(
[a] => 1
[c] => 3
[b] => 42
)
[2,0] => Array
(
[d] => 4
)
)
The 'a' and 'z' keys of the array with key '4' were not combined because the threshold for combinations is 3, and combining them would result in a combined array with only two elements.
The arrays with keys '2' and '0' were combined because after extracting the combinations, these two arrays were identical, and the threshold has no effect for identical arrays, they are always combined.
统计信息
- 总下载量: 130
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2016-12-13