2
So, I’ve been banging my head for a while now with a basic question of scope, but I couldn’t figure out why.
In the function below, I am trying to access a position of the object that is running at the time of Foreach, however it is giving the variable $vInfo as Undefined.
If I var_dump it before this array_filter, it will be normal, only in there does not work. What would be the real problem and how can I access the object inside the array_filter?
foreach ($vehiclesInfo as $vInfo) {
$splitOpenedIdleEvents = array_filter($openedEvents, function($o){
return $o->vehicleid == $vInfo->v_id;
});
Related: What is the difference between global and superglobal variables?
– Woss
@Andersoncarloswoss opa, thank you very much!
– Vinicius Gabriel