Answers for "Use external variable in array_filter"

PHP
0

Use external variable in array_filter

$foo = array_filter($bar, function($obj) use ($id) {
    if (isset($obj->foo)) {
        var_dump($id);
        if ($obj->foo == $id) return true;
    }
    return false;
});
Posted by: Guest on October-07-2021

Browse Popular Code Answers by Language