I am making a log file which logs in the following manner:
[08-12-2016 22:59:38.000000] [Error] Testing
[08-12-2016 22:59:45.000000] [Error] Testing
[08-12-2016 23:03:37.000000] [warning] Testing
I am trying to make a function which can read total warning and total errors in log file. The following code works fine. The question is: Is there a better way to do this?
$file = file( $complete_filename );
$totalErrors = 0;
$totalWarnings = 0;
foreach($file as $rows) {
if(strpos( $rows, "[warning]")) $totalWarnings ++;
if(strpos( $rows, "[Error]")) $totalErrors ++;
}
echo "$totalWarnings/$totalErrors";