How to create and format a text file?
Posted: Tue Jun 13, 2006 12:39 pm
Hi all.
I want to create a string where text and variables are added in this string (see example below), and finally mail()'ed as an attachment. The text must be in plain, so no html. I would like to know how to format the text file so that I can have newlines and eventually tabulation when needed. However, it appears that \n and \t doesn't have any effect.
I have read that for html-pages, I need to use <br> instead, yet this is not a html-page but plain text.
I also understand that a newline is OS-dependent, ie in Win it should be \r\n, and in Linux it should be \n. I've tried both but the email is still messy.
Finally, in php.net I've seen an example how OR'ing some numbers can "create" a backspace. Is this the way to go to "create" newlines and tabulation? If so, what are the numbers to OR?
Thanks in advance!
$string = $data[0] . "\n";
$string .= $data[1] . "\n";
$string .= $data[2] . "\n";
I want to create a string where text and variables are added in this string (see example below), and finally mail()'ed as an attachment. The text must be in plain, so no html. I would like to know how to format the text file so that I can have newlines and eventually tabulation when needed. However, it appears that \n and \t doesn't have any effect.
I have read that for html-pages, I need to use <br> instead, yet this is not a html-page but plain text.
I also understand that a newline is OS-dependent, ie in Win it should be \r\n, and in Linux it should be \n. I've tried both but the email is still messy.
Finally, in php.net I've seen an example how OR'ing some numbers can "create" a backspace. Is this the way to go to "create" newlines and tabulation? If so, what are the numbers to OR?
Thanks in advance!
$string = $data[0] . "\n";
$string .= $data[1] . "\n";
$string .= $data[2] . "\n";