Reputation: 7602
I want to check that an array has no values or that the values in the array are empty. Can someone explain how to do this?
Upvotes: 8
Views: 6205
Reputation: 157981
Someday I've learned very smart solution here on SO
if(!array_filter($array)) {
//array contains only empty values
}
or even smarter one (if applicable):
if(!array_filter($array,'trim')) {
//array contains only empty values
}
Upvotes: 21
Reputation: 4707
You want the empty()
function, here's the documentation of the empty function http://php.net/manual/en/function.empty.php
Upvotes: 11