timdev/php-array-utils
Composer 安装命令:
composer require timdev/php-array-utils
包简介
Handy php array utilities.
README 文档
README
Everybody who writes a bunch of PHP eventually writes functions to do some common array manipulation tasks.
This is where I'm going to stick all mine. You're welcome to use them, too.
The utilities are implemented as static methods on a class.
As of today, there's only one function:
ArrayUtils::val(array $array, $keys, $default = null)
Digs a value out of an array, or else returns a default value.
use TimDev\ArrayUtils as A; $array = ['foo' => ['bar' => 'baz']]; // $baz == 'baz' $baz = A::val($array, ['foo', 'bar']); // $nope == null $nope = A::val($array, ['foo', 'bork']); // $nope == 'squee' $nope = A::val($array, ['i-do-not-exist'], 'squee'); // if you're just dereferencing by one level, you can pass int/string as second arg: // $foo == ['bar' => 'baz'] $foo = A::val($array, 'foo');
统计信息
- 总下载量: 34
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-02-04