aviator/array-map-keys
最新稳定版本:0.1.0
Composer 安装命令:
composer require aviator/array-map-keys
包简介
Array map with keys
关键字:
README 文档
README
Overview
PHP's array_map() function doesn't allow associative array key mutation. This package provides a function, array_map_keys(), which does.
The function iterates over an array and mutates each array item with the provided callback.
Installation
Via Composer:
composer require aviator/array-map-keys
Testing
Via Composer:
composer test
Usage
An array:
$input = [ [ 'company' => 'Aviator Creative', 'owner' => 'Daniel Deboer', 'email' => 'daniel.s.deboer@gmail.com', ], [ 'company' => 'Widget Makers', 'owner' => 'Jane Doe', 'email' => 'jane@widgets.com', ], ];
A callback:
$callback = function ($key, $value) { return [ $value['owner'] => $value['email']; ]; };
The array_map_keys function:
$results = array_map_keys($input, $callback);
The output:
echo $results; /* [ 'Daniel Deboer' => 'daniel.s.deboer@gmail.com', 'Jane Doe' => 'jane@widgets.com', ] */
Other Stuff
License
This package is licensed with the MIT License (MIT).
统计信息
- 总下载量: 11.68k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 1
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-11-25