DEV Community

Discussion on: Mastering PHP Arrays

Collapse
 
goodevilgenius profile image
Dan Jones
//Array filter (return a filtered array)
$filteredPeople = array_filter($people, function ($person) {
    return $names->active;
});
Enter fullscreen mode Exit fullscreen mode

This also won't work. I think maybe you meant:

//Array filter (return a filtered array)
$filteredPeople = array_filter($people, function ($person) {
    return $person->active;
});
Enter fullscreen mode Exit fullscreen mode

Although, I have no idea what $person is supposed to be, since it's not clear from your examples.

Collapse
 
ericchapman profile image
Eric The Coder

Oupss. Typo $names should be $person

$person is the singular noun of the plural $people