I've the below array of users:
$users = [
[name => 'Alice', age => 22],
[name => 'Bob', age => 23],
[name => 'Charlie', age => 19]
];
I'd like to create an array of users that are at least 20 years old. I tried:
$allowed_users = array_filter($users, function($user) {
return $user->age >= 20;
});
var_dump($allowed_users);
Which returns an empty array. I suppose I'm doing something wrong with the callback function.