foreach( $items as $item) {
$taskid = (int) $goal['goal_id'];
$items[$i]['tasks'] = array();
$items[$i]['tasks'] = array_filter($tasks, function($task, $taskid){
return $task['task_id'] == $taskid;
});
Why is $taskid not being passed to the array_filter function, it returns null if echoed from within but if echoed just after it is set it gives the correct value e.g.
foreach( $items as $item) {
$taskid = (int) $goal['goal_id'];
echo $taskid;
Will return whatever the integer is
The return part of the function also works if I manually set a value i.e
return $task['task_id'] == 2;
Guidance appreciated