What are the advantages and disadvantages of using foreach loops versus implode when deleting multiple entries in PHP?

When deleting multiple entries in PHP, using a foreach loop to iterate over the array of entries and delete each one individually can be advantageous because it allows for more control over each deletion operation. However, using implode to concatenate the array of entries into a single string and then executing a single query to delete all entries at once can be more efficient and reduce the number of database queries executed.

// Using foreach loop to delete multiple entries
foreach($entries as $entry) {
    $sql = "DELETE FROM table_name WHERE id = $entry";
    $result = mysqli_query($conn, $sql);
}

// Using implode to delete multiple entries
$ids = implode(',', $entries);
$sql = "DELETE FROM table_name WHERE id IN ($ids)";
$result = mysqli_query($conn, $sql);