Check If array is null or not in php

后端 未结 6 1112
庸人自扰
庸人自扰 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

    This checks if the array is empty

    if (!empty($result) {
        // do stuf if array is not empty
    } else {
        // do stuf if array is empty
    }
    

    This checks if the array is null or not

    if (is_null($result) {
       // do stuf if array is null
    } else {
       // do stuf if array is not null
    }
    

提交回复
热议问题