📜  PHP 代码示例中的映射、过滤和归约

📅  最后修改于: 2022-03-11 14:53:36.706000             🧑  作者: Mango

代码示例1
function getNames(array $users, $excludeId)
{
    $filtered = array_filter($users, function ($u) use ($excludeId) {
        return $u['id'] != $excludeId;
    });

    return array_map(function ($u) { return $u['name']; }, $filtered);
}