How can the issue of repeating data in emails be avoided when sending emails to multiple recipients in PHP?

Issue: To avoid repeating data in emails when sending to multiple recipients in PHP, you can use the PHP function `ob_start()` to buffer the output, `ob_get_clean()` to get the buffered output and then `str_replace()` to replace the placeholders with the actual data for each recipient before sending the email.

ob_start();
// Email content with placeholders for data
$email_content = "Hello [NAME], your order number is [ORDER_NUMBER].";
$email_body = ob_get_clean();

$recipients = array(
    array("name" => "John", "order_number" => "123"),
    array("name" => "Jane", "order_number" => "456")
);

foreach ($recipients as $recipient) {
    $email_body_modified = str_replace(
        array("[NAME]", "[ORDER_NUMBER]"),
        array($recipient["name"], $recipient["order_number"]),
        $email_body
    );
    
    // Send email to recipient
    mail($recipient["email"], "Subject", $email_body_modified);
}