Link to home
Start Free TrialLog in
Avatar of rbosco020475
rbosco020475

asked on

Line Breaks in a text file using php

I have a log file that I am writing to using php when certain events happen on my web site project. I can open the file, write the entry, and close it ok, but I cannot seem to figure out how to format the text file so that each entry is on a single line in the document.

The code I am using is:

$fp = fopen("./logfiles/insert_log.txt", "a+");
if (!$fp) die ("Cannot open database transaction log");

fwrite($fp, "$subdate|$id|$userid|New record created|success ");
fclose($fp);

The result is:

11/24/2006 00:00:00.000|1001|New record created|success 11/24/2006 00:00:00.000|1001|New record created|success 11/24/2006 00:00:00.000|1001|New record created|success



Anyone know how I can make the result look like this format:   (One line per insert to the file.)

11/24/2006 00:00:00.000|1001|New record created|success
11/24/2006 00:00:00.000|1001|New record created|success
11/24/2006 00:00:00.000|1001|New record created|success



Thanks

ASKER CERTIFIED SOLUTION
Avatar of Robin Hickmott
Robin Hickmott

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rbosco020475
rbosco020475

ASKER

That worked! Something so simple that everyone that I asked so far could not offer as a suggestion. Thanks.
No problem its always the simple things that are the most infuriating :)