Check If array is null or not in php

后端 未结 6 1099
庸人自扰
庸人自扰 2020-12-16 12:15

I have an array like below which is generated by parsing a xml url.

The array is

Array
  (
 [Tags] => SimpleXMLElement Object
    (
        [0] =         


        
6条回答
  •  無奈伤痛
    2020-12-16 13:08

    Corrected;

    /*
     return true if the array is not empty
     return false if it is empty
    */
    function is_array_empty($arr){
      if(is_array($arr)){     
          foreach($arr as $key => $value){
              if(!empty($value) || $value != NULL || $value != ""){
                  return true;
                  break;//stop the process we have seen that at least 1 of the array has value so its not empty
              }
          }
          return false;
      }
    }
    

提交回复
热议问题