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?
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
}
You want the empty()
function, here's the documentation of the empty function http://php.net/manual/en/function.empty.php
精彩评论