I have this script that I made, it basically captures all the files in my "logs" folder and merges them all into one array file, my only problem is that sometimes the script breaks if there are no empty lines or empty lines! How can I say that it automatically skips empty blank lines and moves on to the next? empty lines are not necessarily at the top or bottom! may be in the middle of the csv file
<?php $csv = array(); $files = glob('../logs/*.*'); $out = fopen("newfile.txt", "w"); foreach($files as $file){ $in = fopen($file, "r"); while (($result = fgetcsv($in)) !== false) { $csv[] = $result; } fclose($in); fclose($out); } print json_encode(array('aaData' => $csv )); ?>
source share