Is there a built-in PHP function to check if an array contains elements, and how can it be used to ensure the array is not empty before performing operations on it?

To check if an array contains elements in PHP, you can use the `empty()` function. This function returns true if the array is empty (contains no elements) and false if it has elements. To ensure the array is not empty before performing operations on it, you can use an if statement with `empty()` to check if the array is not empty.

// Check if the array is not empty before performing operations
if (!empty($myArray)) {
    // Perform operations on the array here
    foreach ($myArray as $element) {
        echo $element . "<br>";
    }
} else {
    echo "Array is empty.";
}