What are the advantages and disadvantages of using the foreach loop for processing database results in PHP?

When processing database results in PHP, using a foreach loop can be advantageous as it allows for easy iteration over each row of the result set. This simplifies the code and makes it easier to access and work with individual rows of data. However, using a foreach loop can also lead to performance issues when dealing with large result sets, as it loads all the data into memory at once.

// Assuming $results is the database result set
foreach($results as $row) {
    // Process each row of data here
}