PHPackages                             barley/functions - 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. barley/functions

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

barley/functions
================

Common methods commonly used in projects

v1.0.2(7y ago)012MITPHPPHP &gt;=5.4

Since Dec 26Pushed 6y ago1 watchersCompare

[ Source](https://github.com/BarleyZhang/functions)[ Packagist](https://packagist.org/packages/barley/functions)[ RSS](/packages/barley-functions/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (4)Used By (0)

functions
=========

[](#functions)

项目中常用的一些公用方法

\#引入方法 `include_once __DIR__.'/vendor/autoload.php';``$barley = new barley\functions\Functions;``$is_writable = $barley->is_really_writable('/');`

如果是框架中的话,使用命名空间 use barley\\functions\\Functions as BarleyFunctions; 起个自己觉得方便的别名,使用方法如下: `$ok = BarleyFunctions::is_really_writable('/');`也可以这样: `$ok = new BarleyFunctions(); $ok = $info->is_really_writable('/');`

1. `cleanhtml($str,$tags="")                                       去除html标签`
2. `splitArray($array, $groupNum)                                   将数组分为指定个数`
3. `copydirs($source, $dest)                                        复制文件夹`
4. `rmdirs($dirname, $withself = true)                              删除文件夹`
5. `is_really_writable($file)                                       判断文件或文件夹是否可写`
6. `datetime($time, $format = 'Y-m-d H:i:s')                        将时间戳转换为日期时间`
7. `unique_arr($array2D,$stkeep=false,$ndformat=true)               保留键值,二维数组去重`
8. `toArray($xml)                                                   XML转Array`
9. `delDirAndFile($path, $delDir = FALSE)                           删除文件和文件夹`
10. `arr2xml($data, $root = true)                                   将数组转换为xml`
11. `arrToStr ($array)                                              数组转为字符串`
12. `getDistance($lat1, $lng1, $lat2, $lng2)                        计算两个经纬度的之间的距离`
13. `mutiarray_sort($muti_array, $field, $type=1)                   二维数组根据指定键的值进行升序或是降序排序`
14. `objectToArray($object)                                         对象转数组`
15. `randFloat($min, $max)                                          生成给定两个数之间的随机小数`

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

Total

3

Last Release

2631d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b25d4aec8ce50d1e39eaa70f81cce069a8baba1e55c1959467cf5f8c8242ab4f?d=identicon)[Barley](/maintainers/Barley)

---

Top Contributors

[![BarleyZhang](https://avatars.githubusercontent.com/u/19641090?v=4)](https://github.com/BarleyZhang "BarleyZhang (2 commits)")

### Embed Badge

![Health badge](/badges/barley-functions/health.svg)

```
[![Health](https://phpackages.com/badges/barley-functions/health.svg)](https://phpackages.com/packages/barley-functions)
```

PHPackages © 2026

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