开发者

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

开发者 https://www.devze.com 2023-02-24 03:25 出处:网络
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

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

精彩评论

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