What is the best way to check if the main content of an object fetched via fetchAll() is empty in PHP?

When using fetchAll() in PHP to retrieve data from a database, the result is returned as an array of rows. To check if the main content of this object is empty, you can simply use the empty() function to check if the array is empty or not. This will allow you to determine if there are any rows fetched from the database or not.

// Fetch data from database
$data = $stmt->fetchAll();

// Check if main content is empty
if (empty($data)) {
    echo "No data found.";
} else {
    // Process fetched data
    foreach ($data as $row) {
        // Do something with each row
    }
}