See the documentation page on empty()
:
Note: Because this is a language construct and not a function, it cannot be called using variable functions
So basically empty()
is not a function, and because callback must be a function, empty()
can not be passed as callback.
But you can create callback that may use empty()
. The following should work in PHP > 5.3:
$arr = array_filter($arr, function($var){
return empty($var);
});
In PHP < 5.3 you will need to create similar function first and then pass it to the array_filter()
.
Did it help?