(php)如何在array_filter中将类方法作为回调传递? [重复]

This question already has an answer here:

when calling array_filter with a php function you just should do

function myFunc($e) {
    return something($e);
}
array_filter($myArray,"myFunc");

but how do i pass a class method? (static or non-static) for example

class A {
    public function foo() {
        //code
        $a = array_filter($array,"self::myFilter");
        //or if myFilter is an instance method
        $a = array_filter($array,"this->myFilter");
    }
    public (static)? function myFilter($e) {return something($e);}
}

i need because i will reuse my filter function in other places in the class, i tried using anonymous functions in static variables but i get error

</div>

This should work for the instance method version:

class A {
    public function foo() {
        $a = array_filter($array, array($this, "myFilter"));
    }
    public function myFilter($e) {return something($e);}
}

See http://php.net/manual/en/language.types.callable.php