473,320 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Inserting newline characters into a text file

darksteel21
Good Day!

i am looking for way to write or create a text file that contains this format:

This
is
a
sample
tex
t

currently i am using fwrite() function to write text on a file but the output is this:
This is a sample text
i've tried the escape character "\n", but it wont work...
is there a way in php that can write new lines on a text??
Aug 5 '08 #1
4 2313
pbmods
5,821 Expert 4TB
Heya, DarkSteel.

Try using the PHP_EOL constant.
Aug 5 '08 #2
PHP_EOL???Wow, it's new to me...i'll try to research on that!thaaaanks!
Aug 5 '08 #3
coolsti
310 100+
Just a note, don't know if this helps or not: How are you looking at the text file that you created? Are you just dumping it to a browser by any chance? Because HTML will eat up the new lines unless you have the <pre> and </pre> tags to wrap the text.
Aug 5 '08 #4
Just a note, don't know if this helps or not: How are you looking at the text file that you created? Are you just dumping it to a browser by any chance? Because HTML will eat up the new lines unless you have the <pre> and </pre> tags to wrap the text.
Wat do u mean by "How are you looking at the text file that you created? Are you just dumping it to a browser by any chance?"..I am planning to develop a program that can generate HTML template..i want my html files would contain this format:
<html>
<body>
<p>Sample No.1</p>
</body>
</html>


Currently, I am having this output in my html files:

<html><body><p>Sample No.1</p></body></html>

but ill try ur advice on <pre> tags..thanks..
Aug 5 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Leeds, Mark | last post by:
I did more investigation into my previous problem and what happens is that my text file has \r for representing a new line instead of a \n. is there a way to tell the readlines function that the...
1
by: av | last post by:
hi all, i am trying to transfer a text file from client to server. say, my text file on the client side is named like this "afile.txt": on the server side, am storing it by different name i.e...
29
by: runningdog | last post by:
Hi, I would like to be able to embed a newline in a text string. Is there any convienent notation to do this TIA Steve
3
by: utab | last post by:
Dear all, I have a text file in the form of 1 2 3 4 5 6 --------/--------/--------/--------/--------/--------/ (I just used / to better explain the...
1
by: utab | last post by:
Hi there I am trying to read from a file, I am trying to read certain fields,there are 6 fields in this file like --------/--------/--------/--------/--------/--------/ All fields are 8...
2
by: John Salerno | last post by:
If I read a string that contains a newline character(s) into a variable, then write that variable to a file, how can I retain those newline characters so that the string remains on one line rather...
1
Motoma
by: Motoma | last post by:
Hey guys, I have a text file, and I need to insert a newline in it after every 900 characters. Anyone got a nice one-liner for me to do this with?
1
by: linq936 | last post by:
Hi, I read in many places that the string to be outputted by printf() must be ending with newline, for example, it should be printf("Hello World.\n"); instead of printf("Hello World.");
3
by: ofilha | last post by:
I am trying to export the resultset of a query to a character delimited file. I am using the wizard for this. However, one of the fields is 512 characters long and it accepts from form address. It...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.