承接 ahungry/powerset 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

ahungry/powerset

Composer 安装命令:

composer require ahungry/powerset

包简介

Generate a powerset (enumerate all possible values) of a multi-dimensional array

README 文档

README

This is a PHP package that allows you to generate a power set (enumerate all possible values) of a multi-dimensional array.

Installation

Watch for this to be available on packagist, at which point you can install with (update: its on packagist now!):

composer require ahungry/powerset

But in the meantime, to install, clone the repository via:

git clone https://github.com/ahungry/ahungry-powerset.git

and include the file, or add a new VCS reference in your composer.json as such:

    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/ahungry/ahungry-powerset"
        }
    ],
    "require": {
        "ahungry/powerset": "^0.1"
    }

then follow it up with a:

composer update

Using ahungry-powerset

After requiring it (or auto-loading it with composer), you can use it (see blub.php for a sample) via:

use Com\Ahungry\Powerset\Functions as pset;

$b = [[
    'a' => [1,2],
    'b' => [3,4],
]];

pset\powerSet($b);

print_r($b);

which will then produce the following output:

Array
(
    [0] => Array
        (
            [a] => 2
            [b] => 4
        )

    [1] => Array
        (
            [a] => 2
            [b] => 3
        )

    [2] => Array
        (
            [a] => 1
            [b] => 4
        )

    [3] => Array
        (
            [a] => 1
            [b] => 3
        )

)

Oh, and it will work with nested arrays:

    $a = [[
        'a' => 0,
        'x' => [
          ['b' => 1, 'c' => ['a', 'b', 'c']],
          ['b' => 3, 'c' => ['a', 'b', 'c']],
          ['b' => 5, 'c' => ['a', 'b', 'c']],
        ],
        'y' => [7, 8, 9],
      ]];

    ps\powerSet($a);
    $this->assertCount(27, $a); // true

TODO

  • Get package listed on packagist

  • Generate a true power set (include the empty value possibilities)

License

GPLv3

统计信息

  • 总下载量: 195
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2016-06-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固