How to check if a multidimensional array is empty or not?

前端 未结 6 1245
[愿得一人]
[愿得一人] 2021-02-01 05:20

Basically, I have a multidimensional array, and I need to check whether or not it is simply empty, or not.

I currently have an if statement trying to do thi

6条回答
  •  别那么骄傲
    2021-02-01 05:36

    just to be on the save side you want it to remove the empty lines ? or do you want to return if any array is empty ? or do you need a list which positions are empty ?

    this is just a thought and !!! not tested !!!

    /**
     * multi array scan 
     * 
     * @param $array array
     * 
     * @return bool
     */
    function scan_array($array = array()){
      if (empty($array)) return true;
    
      foreach ($array as $sarray) {
        if (empty($sarray)) return true;
      } 
    
      return false;
    }
    

提交回复
热议问题