How can one ensure that line breaks are preserved when decoding MIME headers in PHP?
When decoding MIME headers in PHP, the built-in function `imap_mime_header_decode` can be used. To ensure that line breaks are preserved, we can iterate through the decoded parts and concatenate them with a newline character. This will maintain the original formatting of the header.
$headers = imap_mime_header_decode($header);
$decodedHeader = '';
foreach ($headers as $part) {
$decodedHeader .= $part->text . "\n";
}
echo $decodedHeader;