PHPackages                             alter403219353/m-tool - 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. alter403219353/m-tool

ActiveLibrary

alter403219353/m-tool
=====================

这是一个常用的php工具类

1.0.4(7y ago)018MITPHPPHP &gt;=5.3

Since Aug 9Pushed 7y agoCompare

[ Source](https://github.com/alter403219353/MTool)[ Packagist](https://packagist.org/packages/alter403219353/m-tool)[ Docs](https://github.com/alter403219353/m-tool)[ RSS](/packages/alter403219353-m-tool/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)DependenciesVersions (6)Used By (0)

这是一个常用的php工具类

```
use MTool\MToolBase;

//数组类常用方法

            $MToolBase = new MToolBase();

            $data[3] =[
                'id'    =>1,
                'name' =>'test1',
                'type' =>1,
            ];

            $data[4] =[
                'id'    =>2,
                'name' =>'test2',
                'type' =>1,
            ];

            $data[5] =[
                'id'    =>3,
                'name' =>'test3',
                'type' =>2,
            ];

            $data1 = [

                [
                    'id'    =>1,
                    'name' =>'test1',
                ],
                [
                    'id'    =>2,
                    'name' =>'test2',
                ]

            ];

            //过滤条件返回结果(默认为保留索引)
            $r1 = $MToolBase->_Array()->_filter($data,['type'=>1]);

            print_r($r1);

Array
(
    [3] => Array
        (
            [id] => 1
            [name] => test1
            [type] => 1
        )

    [4] => Array
        (
            [id] => 2
            [name] => test2
            [type] => 1
        )

)

            //过滤条件返回结果)不保留索引)
            $r2 = $MToolBase->_Array()->_filter($data,['type'=>1],false);

            print_r($r2);

Array
(
    [0] => Array
        (
            [id] => 1
            [name] => test1
            [type] => 1
        )

    [1] => Array
        (
            [id] => 2
            [name] => test2
            [type] => 1
        )

)

            //回调过滤条件(保留索引)
            $r3 = $MToolBase->_Array()->_filter($data,function ($k,$v){

                    return $v['type'] == 1;
            });

            print_r($r3);

Array
(
    [3] => Array
        (
            [id] => 1
            [name] => test1
            [type] => 1
        )

    [4] => Array
        (
            [id] => 2
            [name] => test2
            [type] => 1
        )

)

            //回调过滤条件(不保留索引)
            $r4 = $MToolBase->_Array()->_filter($data,function ($k,$v){

                return $v['type'] == 1;

            },false);

            print_r($r4);

Array
(
    [0] => Array
        (
            [id] => 1
            [name] => test1
            [type] => 1
        )

    [1] => Array
        (
            [id] => 2
            [name] => test2
            [type] => 1
        )

)

            //删除数组(数组为$r3)
            $r5  = $MToolBase->_Array()->_remove($data,$r3);

            print_r($r5);

Array
(
    [5] => Array
        (
            [id] => 3
            [name] => test3
            [type] => 2
        )

)

            /**根据两个数组的条件来修改要修改的数组,返回第一个数组修改的数据(仅支持两个数组层级是一层)
             * @param $data   数组1
             * @param $data1  数组2
             * @param $where   条件路径   ['id=>id',*] //多个数组条件     数组1(键值)=>数组2(键值)=,*  id 为键名
             * @param $mod_data 要修改的字段数据  ['stauts'=>1,'delete'=>1] 数字不区分条件  ['stauts'=>[1,0],'delete'=>[1,0]]   数组按条件区分 数组[0] 匹配条件 数组[1] 不匹配条件
             */

            $where     = ["id=>id"];

            $mod_data = ["status"=>[1,0],'delete'=>1];

            $r6  = $MToolBase->_Array()->_mod_filter($data,$data1,$where,$mod_data);

            print_r($r6);

Array
(
    [3] => Array
        (
            [id] => 1
            [name] => test1
            [type] => 1
            [status] => 1
            [delete] => 1
        )

    [4] => Array
        (
            [id] => 2
            [name] => test2
            [type] => 1
            [status] => 1
            [delete] => 1
        )

    [5] => Array
        (
            [id] => 3
            [name] => test3
            [type] => 2
            [status] => 0
            [delete] => 1
        )

)

            //数组排序(默认为保留索引) 排序参数 desc  升序  asc 降序
            $r7   = $MToolBase->_Array()->_sortBy($data,['id'=>'desc']);

            print_r($r7);

Array
(
    [5] => Array
        (
            [id] => 3
            [name] => test3
            [type] => 2
        )

    [4] => Array
        (
            [id] => 2
            [name] => test2
            [type] => 1
        )

    [3] => Array
        (
            [id] => 1
            [name] => test1
            [type] => 1
        )

)

            //数组排序(不保留索引) 排序参数 desc  升序  asc 降序
            $r8   = $MToolBase->_Array()->_sortBy($data,['id'=>'desc'],false);

            print_r($r8);

Array
(
    [0] => Array
        (
            [id] => 3
            [name] => test3
            [type] => 2
        )

    [1] => Array
        (
            [id] => 2
            [name] => test2
            [type] => 1
        )

    [2] => Array
        (
            [id] => 1
            [name] => test1
            [type] => 1
        )

)
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity61

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

Every ~0 days

Total

5

Last Release

2829d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0cce01db9bcb72a7488c073110b7f6a3b4a3f2468cfd217b30a67dbaa1e1aa45?d=identicon)[alter403219353](/maintainers/alter403219353)

---

Top Contributors

[![alter403219353](https://avatars.githubusercontent.com/u/33739048?v=4)](https://github.com/alter403219353 "alter403219353 (16 commits)")

### Embed Badge

![Health badge](/badges/alter403219353-m-tool/health.svg)

```
[![Health](https://phpackages.com/badges/alter403219353-m-tool/health.svg)](https://phpackages.com/packages/alter403219353-m-tool)
```

PHPackages © 2026

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