开发者

How do I determine if an array is empty in PHP?

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜