定制 jelle-s/arraykeycombiner 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

Build Status Code Climate Test Coverage Issue Count

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2016-12-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固