How to determine if a pool is empty in PHP?

I want to check that the array has no values ​​or that the values ​​in the array are empty. Can someone explain how to do this?

+7
source share
2 answers

Someday I found out a very smart solution here on SO

if(!array_filter($array)) { //array contains only empty values } 

or even smarter (if applicable):

 if(!array_filter($array,'trim')) { //array contains only empty values } 
+18
source

You need the empty() function, here is the documentation of the empty function http://php.net/manual/en/function.empty.php

+11
source

All Articles