When it find the data it is suppose to open a log file and insert the entries into there.
That all works!! Yeah me!! But the problem is I am trying to add some headings and such. When i call the file_put_contents and try and do a /n or a /n/r it does not put an line return in there. Any ideas???
Here is my code:
Code: Select all
<?php
$valid_date=array("1/4/2007","1/9/2007","1/17/2007","1/22/2007","1/25/2007","1/30/2007","2/2/2007");
$d=dir('c:\scripts\logs');
while (false !== ($file = $d->read())){
if ($file === "." || $file === "..")
{
// do nothing
}
else {
$path2 = "c:\scripts\logs\\$file";
echo $path2."\n";
$test = file($path2);
file_put_contents ('c:\scripts\sample.txt', "Data came from $file \n\r", FILE_APPEND);
file_put_contents ('c:\scripts\sample.txt', "-------------------------------------".'\n\r', FILE_APPEND);
foreach ($test as $item){
if (in_array(rtrim(substr($item,0,9)), $valid_date)){
echo $item." \n";
file_put_contents ('c:\scripts\sample.txt', "$item", FILE_APPEND);
}
}
}
}
$d->close();
?>