Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Mapping, Filtering and Reducing in PHP

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);
}
Source by eddmann.com #
 
PREVIOUS NEXT
Tagged: #Filtering #Reducing #PHP
ADD COMMENT
Topic
Name
5+8 =