The simple thing I am trying to do below is to read a big error log file (35MB - could have been bigger :), and filter out some lines that are spamming my logs, those containing the x-mapp string.
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$handle = @fopen("error.log", "r");
if ($handle) {
$i=0;
while (($line = fgets($handle, 4096)) !== false) {
if (strpos($line, 'x-mapp') !== FALSE){}
else {
echo $line.'<br>';
}
$i++;
}
if (!feof($handle)) {
echo "Error: unexpected fgets() fail
";
}
echo $i.' proccessed';
fclose($handle);
} else {
echo 'error';
}
echo 'finished';
The output I am getting is like this:
line-1 that doesn't contain x-mapp
line-2 that doesn't contain x-mapp
line-3 that doesn't contain x-mapp
line-4 that doesn't contain x-mapp
For some strange reason, the reading of the error.log file is stopped without any error/warning. I would except sth like this as output:
line-1 that doesn't contain x-mapp
line-2 that doesn't contain x-mapp
line-3 that doesn't contain x-mapp
line-4 that doesn't contain x-mapp
Many more lines not containing x-map
782933 processed
finished
Any ideas? Thanks for your time!