I'm trying to use the code from answer to this question: Count values in subarray
But it doesn't want to work with variables?
So for instance, this works:
echo count(array_filter($tasks, function($element){
return $element['parent'] == 15;
}));
Echoes out: 4
But this fails:
$number = 15;
//Kolla ifall denna har subtasks?
echo count(array_filter($tasks, function($element) {
return $element['parent'] == $number;
}));
Echoes out 0
Any ideas as to why?