Skip to content
Advertisement

Check if an array of array is empty

I got the following array:

JavaScript

I want to process it if not empty. I have tried:

JavaScript

But this returns

filled

Edit after Marcin Orlowski answer

JavaScript

shows:

JavaScript

Advertisement

Answer

As far as I understand in your code the function User() of your object $data returns your mentioned array. If this is the case then $data->User() (i.e. your array) is for sure non empty since it has one entry which is the array

JavaScript

If you want to check if the ‘name’ and ‘firstname’ properties are empty then you need a piece of code like this,

JavaScript

or even better check it in your class, i.e. by writing a piece of code like this in the class for $data

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement