Hi..
I am reading the following file into an array
Name-Grade-Room
Sart, Joe 8 1016
Doe, John 7 659
Notas, Mariangela 3 1504
Zeph, Mike 8 866
Dept, Franc 6 862
I need to then sort the array alphabetically by last name and also descending by room. For some reason I can't do this. When I read this into a file i explode the file using a for loop with the name as the first element, grade as the element, and room as the last element in the array.
You have to keep the associated grade and room number when you sort by last name or room.
Can someone please help me with the code. I am new to PHP and would appreciate it.
Here is my code so far:
$TheFile = "rooms.txt";
$Open = fopen ($TheFile, "r");
if($Open){
$Data = file($TheFile, "r");
for ($n=0; $n<count($Data); $n++) {
$GetLine = explode("\t", $Data[$n]);
sort($GetLine);
echo ("<table width = '100%'>
<tr><td width='60%'$GetLine[0]</td>
<td width='20%'>$GetLine[1</td>
<td width='20%'>$GetLine[2]</td></tr>
</table>");
}
fclose($Open);
}
else {
echo("error");
}
?>
Thanks
Alex