spatie/array-functions
Composer 安装命令:
composer require spatie/array-functions
包简介
Some handy array helpers
README 文档
README
This package provides some handy array functions.
Spatie is a webdesign agency in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.
Support us
We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.
Postcardware
You're free to use this package (it's MIT-licensed), but if it makes it to your production environment you are required to send us a postcard from your hometown, mentioning which of our package(s) you are using.
Our address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium.
The best postcards will get published on the open source page on our website.
Install
You can install this package via composer:
composer require spatie/array-functions
Usage
The following functions are provided in the Spatie-namespace:
array_rand_value
/** * Get a random value from an array. * * @param array $array * @param int $numReq The amount of values to return * @return mixed */ function array_rand_value(array $array, $numReq = 1)
array_rand_weighted
/** * Get a random value from an array, with the ability to skew the results. * Example: array_rand_weighted(['foo' => 1, 'bar' => 2]) has a 66% chance of returning bar. * * @param array $key * * @return mixed */ function array_rand_weighted(array $array)
values_in_array
/** * Determine if all given needles are present in the haystack. * * @param array|string $needles * @param array $haystack * * @return bool */ function values_in_array($needles, array $haystack)
array_keys_exist
/** * Determine if all given needles are present in the haystack as array keys. * * @param array|string $needles * @param array $haystack * * @return bool */ function array_keys_exist($needles, array $haystack)
array_split_filter
/** * Returns an array with two elements. * * Iterates over each value in the array passing them to the callback function. * If the callback function returns true, the current value from array is returned in the first * element of result array. If not, it is return in the second element of result array. * * Array keys are preserved. * * @param array $array * @param callable $callback * @return array * */ function array_split_filter(array $array, callable $callback)
array_split
/** * Split an array in the given amount of pieces. * * @param array $array * @param int $numberOfPieces * @param bool $preserveKeys * @throws \InvalidArgumentException * @return array */ function array_split(array $array, $numberOfPieces = 2, $preserveKeys = false)
array_merge_values
/** * Returns an array with the unique values from all the given arrays * * @param \array[] $arrays * @return array */ function array_merge_values(array ... $arrays)
array_flatten
/** * Flatten an array of arrays. The `$levels` parameter specifies how deep you want to * recurse in the array. If `$levels` is -1, the function will recurse infinitely. * * @param array $array * @param int $levels * * @return array */ function array_flatten(array $array, $levels = -1)
Change log
Please see CHANGELOG for more information what has changed recently.
Testing
You can run the tests with:
vendor/bin/phpunit
Contributing
Please see CONTRIBUTING for details.
Security
If you've found a bug regarding security please mail security@spatie.be instead of using the issue tracker.
Credits
About Spatie
Spatie is a webdesign agency in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.
License
The MIT License (MIT). Please see License File for more information.
spatie/array-functions 适用场景与选型建议
spatie/array-functions 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 65.76k 次下载、GitHub Stars 达 245, 最近一次更新时间为 2015 年 05 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「array」 「helper」 「handy」 「spatie」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 spatie/array-functions 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 spatie/array-functions 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 spatie/array-functions 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
String handling evolved
A set of useful PHP classes.
Datetime helpers for timezone handling
Trait providing methods to set class properties with an array.
Library with classes to help you do batch.
Traits to build collections of specific objects
统计信息
- 总下载量: 65.76k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 248
- 点击次数: 28
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-05-20