Warning: array_filter() expects parameter 2 to be a valid callback,
function ’empty’ not found or invalid function name….
Why is empty considered a invalid callback?
$arr = array_filter($arr, 'empty');
This works: if(empty($arr['foo'])) die();
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Answer
empty()is not a function but a language construct andarray_filter()can only accept a function as its callback.This is given as a small note on the manual page:
Work around
To work around this you can wrap empty in another function for example:
And then call it like so: