Line break while writing txt file using php & form data

vaibhavy

New Member
Messages
3
Reaction score
0
Points
0
I am writing (appending) a txt file with form data, using PHP. Since there are multiple form elements (textbox), i want each value to be written in txt file on new line.
But out of "\n\r", "\r\n","\n" ,"\r" nothing is working. It just creates space and doesnt break the line please help.
 

fortwienix

New Member
Messages
9
Reaction score
0
Points
0
A normal "\n" in double quotes should do the trick.
PHP:
$fp = fopen('your_file_name.txt', 'a+');
fputs($fp, $formfield_1."\n".$formfield_2."\n");
fclose($fp);

"\r\n" is needed on Windows based systems.
 

miguelkp

Member
Messages
304
Reaction score
7
Points
18
Hum. I think what you need are those functions:

string nl2br(string) = you should input a string and a string outputs with every \n converted in a <br />

string br2nl(string) = you should input a string and a string outputs with every <br /> converted in a <br />

Edit: sorry, I didn't understand you. Forgot this.
 
Last edited:
Top