Page 1 of 1

How to create and format a text file?

Posted: Tue Jun 13, 2006 12:39 pm
by photonatic
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";

Posted: Tue Jun 13, 2006 1:23 pm
by MrPotatoes
i'm pretty sure i added tabs to my text file as i wrote it. it was in the installer and created the config file for you. but i forget how to do it off hand.

but i have to get home to show ya. unless someone else here knows how :)

Posted: Tue Jun 13, 2006 5:11 pm
by photonatic
A friend pointed out the problem. I had defined the mail-header's Content-Type to text/html, so that the mail was interpreted as a html-page, thus the newline wouldnt work. Thanks MrPotatoes for ur reply anyway. :-)