How to check if a multi-dimensional array only contains empty values?

前端 未结 3 1287
野趣味
野趣味 2021-02-06 19:20

I looked around and can\'t quite find the answer for this, so I\'m wondering if I contain an array such as this..

$array[\'foo\'][\'bar\'][1] = \'\';
$array[\'fo         


        
3条回答
  •  迷失自我
    2021-02-06 19:43

    A short alternative would be:

    if (empty(implode($array['foo']['bar']))) {
      // is empty
    }
    

    Note that some single values may be considered as empty. See empty().

提交回复
热议问题