I have a big set of time records for a project and I want to filter out all but those posted by a single employee.
array_walk($timeRecords, function($timeRecord, $index) use ($employee) {
if ($timeRecord->employeeId != $employee->id) {
unset($timeRecords[$index]);
}
});
You can see what I'm trying to do. How do you go about doing this with anon functions and closures? Obviously $timeRecords is not defined inside the anonymous function. Thanks.