So, I've been banging my head for some time now with a basic scope question, but I could not figure out why.
In the function below, I'm trying to access a position of the object that is running at the time of Foreach, though it is giving the $ vInfo variable as Undefined.
If I give a var_dump on it before this array_filter, it goes normal, only in there it does not work. What would be the real problem and how do I get access to the object inside the array_filter?
foreach ($vehiclesInfo as $vInfo) {
$splitOpenedIdleEvents = array_filter($openedEvents, function($o){
return $o->vehicleid == $vInfo->v_id;
});