What is the best way to check if an array is empty in PHP before running a loop?

To check if an array is empty in PHP before running a loop, you can use the `empty()` function. This function returns true if the array is empty (contains no elements) and false if it has elements. By checking if the array is empty before running a loop, you can avoid unnecessary iterations and potential errors.

// Check if the array is empty before running a loop
if (empty($array)) {
    echo "Array is empty";
} else {
    foreach ($array as $value) {
        // Loop through the array
        echo $value . "<br>";
    }
}