PHP array_filter advanced

07 May 2020
0 Comments

1. Use external variable in array_filter

                
                    
$id = '1';
var_dump($id);
$foo = array_filter($bar, function($obj) use ($id) {
    if (isset($obj->foo)) {
        var_dump($id);
        if ($obj->foo == $id) return true;
    }
    return false;
});
                
            

Leave a Reply

This site uses cookies to offer you a better browsing experience. By browsing this website, you agree to our use of cookies.