Hi Friends,
I am facing a problem i want to create a file from different variables having date i.e:
$cheadline or $qsummary.
Now after cancatenation of these variables i have another variable that is $combine.
$combine=$cheadline.'\n'.$qsummary.'\n'.$fpara.'\n'.$lsentence.'\n'.$summrize.'\n'.$cinfo;
When i am using that code
$handle = fopen($filename, "w");
fwrite($handle,$combine);
Then file will be created but all the data are written on same line, without line break.
Please help me how can i break the line after the data of each variable.
Thank and Regards
Line Break Problem in .txt file
Moderator: General Moderators
-
habib009pk
- Forum Commoner
- Posts: 43
- Joined: Sun Jul 05, 2009 11:28 pm
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: Line Break Problem in .txt file
"\n" not '\n'
i.e. double quotes, not single quotes
i.e. double quotes, not single quotes
-
habib009pk
- Forum Commoner
- Posts: 43
- Joined: Sun Jul 05, 2009 11:28 pm
Re: Line Break Problem in .txt file
My Friend,
Thanks but it is not Working, I also tested it..
Regards
Thanks but it is not Working, I also tested it..
Regards
-
habib009pk
- Forum Commoner
- Posts: 43
- Joined: Sun Jul 05, 2009 11:28 pm
Re: Line Break Problem in .txt file
Thanks for you Cooperation
It is solved by that code my self
It is solved by that code my self
Code: Select all
$seperate="
";
$string=$cheadline.$seperate.$qsummary.$seperate.$fpara.$seperate.$lsentence.$seperate.$summrize.$seperate.$cinfo.$seperate;
$filename = "file.txt";
$handle = fopen($filename, "w");
fwrite($handle,$string);
fclose($handle);
Last edited by Benjamin on Thu Aug 06, 2009 6:19 am, edited 1 time in total.
Reason: Changed code type from text to php.
Reason: Changed code type from text to php.
Re: Line Break Problem in .txt file
Mark Baker provided you with a correct response. You may want carriage returns as well. In that case either of the following would work.
Code: Select all
$string= "$cheadline\r\n$qsummary\r\n$fpara\r\n$lsentence\r\n$summrize\r\n$cinfo\n";
$string = implode("\r\n", array($cheadline, $qsummary, $fpara, $lsentence, $summrize, $cinfo));