How to check whether an array is empty using PHP?

Posted by LaravelIndia - 1 year ago

Using empty() Function: This function determines whether a given variable is empty. This function does not return a warning if a variable does not exist. Syntax:

bool empty( $var )


// Declare an array and initialize it 
$non_empty_array = array('URL' => ''); 

// Declare an empty array 
$empty_array = array(); 

// Condition to check array is empty or not 
    echo "Given Array is not empty <br>"; 

    echo "Given Array is empty";