BTW: This happens because HTML does not interpret line breaks. The nl2br (new line to break) function inserts XHTML line breaks (<br/>) where ever newline characters (\n) occur in the string.
Besides server-side technologies like PHP, there are a few client-side options as well.
echo "<pre>\n".
$variable.
"</pre>\n";
Then add a stylesheet rule for browsers that don't support the <pre> element, though I can't remember ATM which browsers don't support it.
pre {
display: block;
white-space: pre;
}
The preceding CSS rule preserves both the whitespace and the line breaks.
HTH!
Regards,
Rich
--
[
http://www.smilingsouls.net]
[
http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail