emeraldinspirations/lib-helper-array

1.1.0 2017-09-05 05:59 UTC

This package is not auto-updated.

Last update: 2024-09-25 03:07:07 UTC


README

Logo of the project

lib-helper-array

emeraldinspiration's library中的一个辅助工具。

此项目的目标是保存常用的函数,以帮助操作基本PHP数据类型。

安装/入门

此项目没有依赖项,因此可以简单地使用composer进行要求

composer require emeraldinspirations/lib-helper-array

特性

  • mapElementFunction - 在数组元素内使用函数执行array_map
  • xor - 返回只包含所提供数组中元素的数组

示例 - mapElementFunction

<?php

use emeraldinspirations\library\helper\phpArray\PhpArray;

class DummyObject
{
    public function test(...$Append)
    {
        return $Char . implode('', $Append);
    }
    public function __construct($Char)
    {
        $this->Char = $Char;
    }
}

$Array = [
    new DummyObject('A'),
    new DummyObject('B'),
    new DummyObject('C'),
];

return PhpArray::mapElementFunction('Test', $Array, 1, 2, 3);

// Returns: ['A123', 'B123', 'C123']

示例 - xor

<?php

use emeraldinspirations\library\helper\phpArray\PhpArray;

$Array1         = ['Foo', 'FooBar',        'Bar'       ];
$Array2         = [                 'foo', 'Bar', 'bar'];

return PhpArray::xor($Array1, $Array2),

// Returns:       ['Foo', 'FooBar', 'foo',        'bar'];

贡献

我希望扩展这个类以包括其他函数。如果您想做出贡献,请fork仓库并使用功能分支。我刚开始使用GitHub,很乐意收到拉取请求来学习如何进行。

我也欢迎对我在遵守标准和“最佳实践”方面的反馈。我已经独自编写软件多年,正在学习如何更好地与他人合作。

许可

此项目中的代码根据MIT许可进行许可。