PHPackages                             aisuhua/php-array - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. aisuhua/php-array

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

aisuhua/php-array
=================

1.0.0(10y ago)027PHP

Since Feb 22Pushed 10y ago1 watchersCompare

[ Source](https://github.com/aisuhua/php-array)[ Packagist](https://packagist.org/packages/aisuhua/php-array)[ RSS](/packages/aisuhua-php-array/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

PHPArray
========

[](#phparray)

对 PHP 数组的常用操作进行封装，目前包括以下方法：`arrayColumn` （提供 PHP &lt; 5.5.0 版本对 `array_column` 的支持）、`objectToArray` 把对象转换为数组。

其中，对 `array_column` 参照了 [array\_column](https://github.com/ramsey/array_column)，如果只需要对 `array_column` 的支持，推荐直接引入原作者的库即可。

安装
--

[](#安装)

通过 Composer 安装：

```
php composer.phar require aisuhua/php-array

```

使用
--

[](#使用)

```
use Aisuhua\PHPArray

array PHPArray::arrayColumn ( array $input , mixed $column_key [, mixed $index_key ] )

array PHPArray::objectToArray ( object $obj )

```

例子
--

[](#例子)

### arrayColumn()

[](#arraycolumn)

```
use Aisuhua\PHPArray;

//记录
$records = array(
    array(
        'id' => 2135,
        'first_name' => 'John',
        'last_name' => 'Doe',
    ),
    array(
        'id' => 3245,
        'first_name' => 'Sally',
        'last_name' => 'Smith',
    ),
    array(
        'id' => 5342,
        'first_name' => 'Jane',
        'last_name' => 'Jones',
    ),
    array(
        'id' => 5623,
        'first_name' => 'Peter',
        'last_name' => 'Doe',
    )
);

$result = PHPArray::arrayColumn($records, 'first_name', 'id');

print_r($result);

```

//运行结果如下：

```
Array
(
    [2135] => John
    [3245] => Sally
    [5342] => Jane
    [5623] => Peter
)

```

### objectToArray()

[](#objecttoarray)

```
use Aisuhua\PHPArray;

class Computer
{
    public $cpu;
    public $screen;
    public $cdrom;

    public function __construct($cpu, $screen, $cdrom)
    {
        $this->cpu = $cpu;
        $this->screen = $screen;
        $this->cdrom = $cdrom;
    }
}

$computer = new Computer('英特尔 I3', '三星显示屏', '华硕刻录机');

$result = PHPArray::objectToArray($computer);

print_r($result);

```

//运行结果如下：

```
Array
(
    [cpu] => 英特尔 I3
    [screen] => 三星显示屏
    [cdrom] => 华硕刻录机
)

```

### 其他

[](#其他)

继续完善

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3781d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/11390617?v=4)[aisuhua](/maintainers/aisuhua)[@aisuhua](https://github.com/aisuhua)

---

Top Contributors

[![aisuhua](https://avatars.githubusercontent.com/u/11390617?v=4)](https://github.com/aisuhua "aisuhua (5 commits)")

### Embed Badge

![Health badge](/badges/aisuhua-php-array/health.svg)

```
[![Health](https://phpackages.com/badges/aisuhua-php-array/health.svg)](https://phpackages.com/packages/aisuhua-php-array)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
