I have a csv file which has this type of rows
This file has 240 rows with above data and somehow it has 700+ empty rows.. when I use this code to check for rows
function fn_get_order_csv($file){
$all_rows = array();
if (($handle = fopen($file[0]['path'], "r")) !== FALSE) {
$headers = fgetcsv($handle);
if(!empty($headers)){
foreach($headers as $key=>$value){
$headers[$key] = str_replace( ':','_',preg_replace('!\s+!', '_', strtolower( trim($value))) );
}
}
while ($row = fgetcsv($handle)) {
if(!empty($row)){
$all_rows[] = array_combine($headers, $row);
}
}
}
return $all_rows;
}
In the above code the If(!empty($row))
still count empty row and return all 900+ rows
But if I change it to If(!empty($row[4]))
it return only 240 rows....
What am I missing to understand it correctly?