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>