kshitizmittal
7 months ago

Scoping Of Variable

Posted 7 months ago by kshitizmittal
foreach ($designations as $key => $value) {
            $count = $users->filter(function ($item)
            {
                return (@$item->designations->degname == $value);
            })->count();            
        }

I want to access the $value variable in the function inside filter function like :- Error Message :-

foreach ($designations as $key => $value) {
            $count = $users->filter(function ($item)
            {
                return (@$item->designations->degname == $value);
            })->count();            
        }

"Undefined variable: value"

Please sign in or create an account to participate in this conversation.