Hello everyone, well I'm having some problems changing line every time my PHP code writes something to a file. Right now, it's writing the time of everyone, who visits my website, then it adds a comma and his ready to write the time of another person that visits the website. Basically now, I need to change line every time it writes the visiting time of someone who visits it, instead of adding a comma. This isn't a particularly easy thing to explain, so I hope I made myself clear. Only one more thing, I have googled about it and I did not find an answer that helped me. Any ideas how can I solve this problem would be appreciated, thanks Dan08.

Recommended Answers

All 2 Replies

Could you give us an example of your problem. A demonstration of how to use new lines in php is as follows.

$text='This is the first line\n';
$text.="This is appended to the first line\n";
$text.='This is the second line separated by a \n';
$text.="\nThis is the last line.";

As you can see new lines are separated by \n but are only separated by \n when in double quotes. So in the above example, 2 of those lines showed a literal \n instead of a \n because they were in single quotes. So if you place a \n in double quotes then that will give you a new line and you can use file_put_contents to place the data into a text file.

I've tried that, but it didn't work. I guess I'm going to try again. Thanks for the reply.

Edit:
Thanks it works. Thread marked as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.