mapping 2c filtering and reducing in php

Solutions on MaxInterview for mapping 2c filtering and reducing in php by the best coders in the world

showing results for - "mapping 2c filtering and reducing in php"
Mila
15 Oct 2016
1function getNames(array $users, $excludeId)
2{
3    $filtered = array_filter($users, function ($u) use ($excludeId) {
4        return $u['id'] != $excludeId;
5    });
6
7    return array_map(function ($u) { return $u['name']; }, $filtered);
8}
9