Splitting files in to an array by 'end of line'.
Posted on 2004-10-27
Need to split a file by the 'end of each line' in to an array.
Currently, if I have EOF at the end of each line I could do it like this:
$logfile = ("LOGS_TMP.TXT");
$handle = fopen($logfile, "r");
$contents = fread($handle, filesize($logfile));
$list = split ('EOF', $contents);
But I don't want to manually add EOF to every line.
$list = file( $logfile,'');
as the results that I am bringing in mess it up with 'Unterminated String Constant'.
Question 1 -
What can I put in place of EOF so that it splits by each line.
Question 2 -
If I can't do Q1, can I add EOF to the end of each file (Without saving it).