schnittstabil / array_some
检查数组中的一些元素或键是否通过由回调函数实现的测试。
1.0.0
2016-04-11 07:37 UTC
Requires
- php: >=5.6.0
Requires (Dev)
- codeclimate/php-test-reporter: ^0.3.0
- fabpot/php-cs-fixer: ^1.10
- satooshi/php-coveralls: ^1.0
- schnittstabil/sugared-phpunit: ^0.3.0
- squizlabs/php_codesniffer: ^2.6
This package is auto-updated.
Last update: 2024-08-26 01:55:09 UTC
README
检查数组中的一些元素或键是否通过由回调函数实现的测试
安装
$ composer require schnittstabil/array_some
使用方法
use function Schnittstabil\ArraySome\array_some; array_some(['l', 'e', 'e', 't'], 'is_string'); // => true array_some([ 1, 3, 3, 7 ], 'is_string'); // => false use function Schnittstabil\ArraySome\array_some_key; array_some_key(['unicorns' => 24], 'is_string'); // => true array_some_key([42 => 'unicorns'], 'is_string'); // => false
API
/** * Checks whether some element in the array passes the test implemented by the callback function. * * @param array $array The array to iterate over * @param callable $callback The callback function to use * * @return bool */ function array_some(array $array, callable $callback); /** * Checks whether some key in the array passes the test implemented by the callback function. * * @param array $array The array to iterate over * @param callable $callback The callback function to use * * @return bool */ function array_some_key(array $array, callable $callback);
许可证
MIT © Michael Mayer