Bankin
Bankin

Reputation: 797

php check is array is empty

How to check if array like this

array(3) { [0]=> array(0) { } [1]=> array(0) { } [2]=> array(0) { } }

is actually empty ? Because for me this is an empty array but for the empty() this is an array with 3 elements and for count this is a array with length 3 .. so is there a way to do it without foreaching the array ?

Thank you in advance

Upvotes: 2

Views: 1310

Answers (2)

khatzie
khatzie

Reputation: 2559

It is also stated here

Check whether an array is empty

use array_filter();

Upvotes: 3

nice ass
nice ass

Reputation: 16709

if(!array_filter($array)){
  // empty
}

(docs)

Upvotes: 9

Related Questions