foreach($myFile as $value){
$arr = explode(",",$value);
echo "<tr>";
foreach($arr as $out) {
if ((strcmp($arr[$city], $out)) == 0){
echo "<td><i>" . $out . "</i></td>";
}
else if((strcmp($arr[$pick], $out)) == 0){
$var = ucfirst(strtolower($out));
echo "<td>". $var. "</td>";
unset($var);
}
else{
echo "<td>" . $out . "</td>";
}
$count++;
unset($out);
}
echo "</tr>";
unset($arr);
}
unset($myFile);
The code above is used to read a .csv file and print it as HTML Table. It's working already, but I'm having some troubles with sorting it.
The content of my .csv file is the variable $myFile
.
Now I should sort the array by the column last, how can I do that?
And the other question: Why do I get the Error of Undefined Offset?
The error lines are the if((strcmp(...))
. The array is having 10 entries and the variable values are:
$pick = 9
$city = 5