PHPackages                             hulang/php-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. hulang/php-tool

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

hulang/php-tool
===============

数组转树形处理类、时间助手类、文件及文件夹处理类、字符串操作类、手机号码归属地、银行号归属地、Zip压缩和解压

1.1.36(3mo ago)2709↓20%2Apache-2.0PHPPHP ^7.4 || ^8.0

Since Dec 3Pushed 3mo ago1 watchersCompare

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

READMEChangelog (2)Dependencies (1)Versions (3)Used By (2)

**PHP工具类库**

 您是第 [![](https://camo.githubusercontent.com/087b4c64811624082de1538a853c90079647f25b59c6d141d94ad58755571f4a/68747470733a2f2f70726f66696c652d636f756e7465722e676c697463682e6d652f6769746875623a68756c616e673a7068702d746f6f6c2f636f756e742e737667)](https://camo.githubusercontent.com/087b4c64811624082de1538a853c90079647f25b59c6d141d94ad58755571f4a/68747470733a2f2f70726f66696c652d636f756e7465722e676c697463682e6d652f6769746875623a68756c616e673a7068702d746f6f6c2f636f756e742e737667)位访问者

#### 环境

[](#环境)

- php &gt;=8.0.0
- ext-zlib

##### 助手类

[](#助手类)

- 数组转各种`Tree`
- 时间
- 文件及文件夹
- 字符串
- 手机号码归属地
- 银行号归属地
- Zip压缩和解压

##### 安装

[](#安装)

```
composer require hulang/php-tool

```

##### TreeHelper `数组转各种Tree`

[](#treehelper-数组转各种tree)

```
/**
 * 数组转树形处理类
 * @see \hulang\tool\TreeHelper
 * @package hulang\tool\TreeHelper
 * @mixin \hulang\tool\TreeHelper
 * @method static mixed|array getSubTree($data, $parent = 'pid', $son = 'id', $pid = 0, $lv_name = 'lv', $lv = 0) 子孙树按等级显示
 * @method static mixed|array getSubTreeList($data, $parent = 'pid', $son = 'id', $pid = 0, $child = 'child') 子孙树列表
 * @method static mixed|array getOneMergeTree($data, $html_name = 'html', $html = '├─', $pid = 0, $lv_name = 'level', $lv = 0, $parent = 'pid', $son = 'id') 组合一维数组
 * @method static mixed|array getMultidMergeTree($data, $parent = 'pid', $son = 'id', $pid = 0, $name = 'child') 组合多维数组
 * @method static mixed|array getTree($data, $parent = 'pid', $son = 'id', $sort_type = 0, $name = 'child') 合并成父子树
 * @method static mixed|array getParents($data, $id = 0, $parent = 'pid', $son = 'id') 传递子分类的id返回所有的父级分类数据
 * @method static mixed|array getParentsIds($data, $id, $parent = 'pid', $son = 'id') 传递子分类的id返回所有的父级分类ID
 * @method static mixed|array getChildsId($data, $pid, $parent = 'pid', $son = 'id') 传递父级id返回所有子级id
 * @method static mixed|array getChilds($data, $pid, $parent = 'pid', $son = 'id') 传递父级id返回所有子级分类数据
 */
```

##### FileHelper `文件及文件夹`

[](#filehelper-文件及文件夹)

```
/**
 * 文件及文件夹帮助类
 * @see \hulang\tool\FileHelper
 * @package hulang\tool
 * @mixin \hulang\tool\FileHelper
 * @method static mixed|SplFileInfo getFileAttr($filename = '') 获取文件属性
 * @method static mixed|string getFileMd5($filename = '') 计算文件的MD5值
 * @method static mixed|string getFileSha1($filename = '') 计算文件的 SHA-1 哈希值
 * @method static mixed|bool mkDir($dir = '') 创建目录
 * @method static mixed|string readFile($filename = '') 读取文件内容
 * @method static mixed|bool writeFile($filename = '', $writetext = '', $mode = LOCK_EX) 写文件
 * @method static mixed|bool delFile($filename = '') 删除指定的文件
 * @method static mixed|bool delDir($dirName = '') 删除指定的目录及其内容
 * @method static mixed|int copyDir($source, $toDir, $force = true) 目录拷贝,返回被拷贝的文件数
 * @method static mixed|array getFolder($path = '', $exclude = []) 得到指定目录里的信息
 * @method static mixed|int getDirSize($dir) 统计文件夹大小
 * @method static mixed|int emptyDir($dir) 检测是否为空文件夹
 * @method static mixed|string getFileSizeFormat($byte = 0) 文件大小格式
 * @method static mixed|int getRoundPow($num = 0, $precision = 2) 辅助函数,该函数用来取舍小数点位数的,四舍五入
 * @method static mixed|string getFileExt($fileName) 获取文件扩展名
 * @method static mixed|string getConvertEncoding($string) 转换字符编码
 */
```

##### TimeRun `时间`

[](#timerun-时间)

```
/**
 * 时间助手类
 * @see \hulang\tool\TimeRun
 * @package hulang\tool\TimeRun
 * @mixin \hulang\tool\TimeRun
 * @method static mixed|array daysAgo($day = 1) 返回几天前的时间戳
 * @method static mixed|array daysAfter($day = 1) 返回几天后的时间戳
 * @method static mixed|array today() 返回今日开始和结束的时间戳
 * @method static mixed|array yesterday() 返回昨日开始和结束的时间戳
 * @method static mixed|array week() 返回本周开始和结束的时间戳
 * @method static mixed|array lastWeek() 返回上周开始和结束的时间戳
 * @method static mixed|array month() 返回本月开始和结束的时间戳
 * @method static mixed|array lastMonth() 返回上个月开始和结束的时间戳
 * @method static mixed|array year() 返回今年开始和结束的时间戳
 * @method static mixed|array lastYear() 返回去年开始和结束的时间戳
 * @method static mixed|array dayToNow($day = 1, $now = 1) 获取几天前零点到现在/昨日结束的时间戳
 * @method static mixed|array getDaysAfterTimeStamp($day = 1) 返回几天后的开始和结束的时间戳
 * @method static mixed|int daysToSecond($day = 1) 天数转换成秒数
 * @method static mixed|int weekToSecond($week = 1) 周数转换成秒数
 * @method static mixed|array getTimeDiff($begin_time, $end_time) 获取两个时间|天数/小时数/分钟数/秒数
 * @method static mixed|int getDiffDays($datetime, $new_datetime = null, bool $is_day = false) 返回两个日期相差天数(如果只传入一个日期,则与当天时间比较)
 * @method static mixed|int getAfterDay(int $day = 1, $datetime = null, bool $is_day = false, bool $round = false) 返回N天后的时间戳,传入第二个参数,则从该时间开始计算
 * @method static mixed|array getByTimestamp($datetime) 根据|时间字符串或时间戳|返回传递的开始时间和结束时间
 * @method static mixed|array getBetweenTwoDates($start, $end, $format = 'Y-m-d', $type = 0) 获取两个日期之间的所有日期
 */
```

##### StrHelper `字符串`

[](#strhelper-字符串)

```
/**
 * 字符串操作类
 * @see \hulang\tool\StrHelper
 * @package hulang\tool\StrHelper
 * @mixin \hulang\tool\StrHelper
 * @method static mixed|bool Contains(string $haystack, $needles) 检查字符串中是否包含某些字符串
 * @method static mixed|bool EndsWith(string $haystack, $needles) 检查字符串是否以某些字符串结尾
 * @method static mixed|bool StartsWith(string $haystack, $needles) 检查字符串是否以某些字符串开头
 * @method static mixed|string Random(int $length = 6, int $type = null, string $addChars = '') 生成指定长度的随机字母数字组合的字符串
 * @method static mixed|string Lower(string $value) 字符串转小写
 * @method static mixed|string Upper(string $value) 字符串转大写
 * @method static mixed|int Length(string $value) 获取字符串的长度
 * @method static mixed|string SubStr(string $string, int $start, int $length = null) 截取字符串
 * @method static mixed|string Snake(string $value, string $delimiter = '_') 驼峰转下划线
 * @method static mixed|string Camel(string $value) 下划线转驼峰(首字母小写)
 * @method static mixed|string Studly(string $value) 下划线转驼峰(首字母大写)
 * @method static mixed|string Title(string $value) 转为首字母大写的标题格式
 * @method static mixed|string uuid() 生成 UUID 编码
 * @method static mixed|string uniqidDate(int $size = 16, string $prefix = '') 生成日期编码
 * @method static mixed|string uniqidNumber(int $size = 12, string $prefix = '') 生成数字编码
 * @method static mixed|string text2utf8(string $text, string $target = 'UTF-8') 文本转码
 * @method static mixed|string encrypt($data, string $skey) 数据解密处理
 * @method static mixed|string decrypt(string $data, string $skey) 数据加密处理
 * @method static mixed|string enSafe64(string $text) Base64Url 安全编码
 * @method static mixed|string deSafe64(string $text) Base64Url 安全解码
 * @method static mixed|string enzip($data) 压缩数据对象
 * @method static mixed|string dezip(string $string) 解压数据对象
 */
```

##### PhoneHelper `手机号码归属地`

[](#phonehelper-手机号码归属地)

```
/**
 * 手机号码归属地
 * @see \hulang\tool\PhoneHelper
 * @package hulang\tool\PhoneHelper
 * @mixin \hulang\tool\PhoneHelper
 * @method static mixed|array getData($mobile_number = '', $separator = '') 手机号码归属地
 */
```

##### BankHelper `银行号归属地查询`

[](#bankhelper-银行号归属地查询)

```
/**
 * 银行号归属地查询
 * @see \hulang\tool\BankHelper
 * @package hulang\tool\BankHelper
 * @mixin \hulang\tool\BankHelper
 * @method static mixed|array getData($card_number = '') 银行号归属地
 */
```

##### ZipHelper `Zip压缩和解压`

[](#ziphelper-zip压缩和解压)

```
/**
 * Php Zip压缩和解压
 * @see \hulang\tool\ZipHelper
 * @package hulang\tool\ZipHelper
 * @mixin \hulang\tool\ZipHelper
 * @method static mixed|string|bool|Exception compress($dir = '') 压缩|备份[目录]
 * @method static mixed|string|bool|Exception unzip($package, $dir = '') 解压
 */
```

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance82

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 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 ~470 days

Total

2

Last Release

97d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cfdd63860bdbf00d57b0f2dcc9c4f9816d9d790b5a22ce30516681d748d2abd4?d=identicon)[hulangfy@163.com](/maintainers/hulangfy@163.com)

---

Top Contributors

[![hulang](https://avatars.githubusercontent.com/u/4961831?v=4)](https://github.com/hulang "hulang (145 commits)")

---

Tags

phplibrary

### Embed Badge

![Health badge](/badges/hulang-php-tool/health.svg)

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

PHPackages © 2026

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