I have a csv file and I am trying to get the minimum value for a particular column. However I am not getting an exact value even after exploding the values. After I explode and I do a var_dump on it, it produces a different array for each different row; so each value in the column is the first element of a different array. How do I merge this different arrays into one array in order to find the minimum value in the column, or is there any other way to go about it? Below is my code. Any help will be appreciated.
merging
while (($data = fgetcsv($handle, 0, ",")) !== false) {
$table2Add =false;
if($row >=$x && $row <=$y) {
$table2Add=true; }
if($row == 1) {
$table2 .= '<thead><tr>';
$table2 .= '<th></th>';
$table2 .= '<th>Min</th>';
$table2 .= '<th>Max</th>';
$table2 .= '<th>Average</th>';
$table2 .= '</tr></thead><tbody>';
}
else {
if($table2Add) $table2 .= '<tr><th>Voltage</th>';
for($c = 0; $c <= 10; $c++) {
$value = empty($data[$c]) ? " " : $data[$c];
if($c==1) {
var_dump((explode('STRING',$data[$c])));
//$ar=explode('STRING', $data[$c]);
//var_dump(min($ar));
if ($table2Add) $table2 .='<td>'.round($value,2).'</td>';
}
if($c==2) {
if ($table2Add) $table2 .='<td>'.round($value,2).'</td>';
}
if($c==3) {
if ($table2Add) $table2 .='<td>'.round($value,2).'</td>';
}
}
if($table2Add) $table2 .= '</tr>';
if($table2Add) $table2 .= '<tr><th>Current</th>';
for($c = 0; $c <= 10; $c++) {
$value = empty($data[$c]) ? " " : $data[$c];
if($c==4) {
if ($table2Add) $table2 .='<td>'.round($value,2).'</td>';
}
if($c==5) {
if ($table2Add) $table2 .='<td>'.round($value,2).'</td>';
}
if($c==6) {
if ($table2Add) $table2 .='<td>'.round($value,2).'</td>';
}
}
if($table2Add) $table2 .= '</tr>';
if($table2Add) $table2 .= '<tr><th>Power Factor</th>';
for($c = 0; $c <= 10; $c++) {
$value = empty($data[$c]) ? " " : $data[$c];
if($c==7) {
if ($table2Add) $table2 .='<td>'.round($value,2).'</td>';
}
if($c==8) {
if ($table2Add) $table2 .='<td>'.round($value,2).'</td>';
}
if($c==9) {
if ($table2Add) $table2 .='<td>'.round($value,2).'</td>';
}
}
if($table2Add) $table2 .= '</tr>';
}
$row++;
}