I have a multidimensionnal array containing song information (song #, length, name) that is created and displayed in a table using the following code:
<?php
$u=0
for($i=5; $i<$infoSource; $i=$i+2)
{
$song[$u]=array("songNumber"=>($u+1),
"length"=>$thisCD[$i],
"name"=>$thisCD[($i+1)]);
$u++;
}
?>
<table border=1>
<tbody>
<tr>
<th>Number</th>
<th>Length</th>
<th>Title</th>
</tr>
<?php
if ($tri=='num'){
}
if ($sort=='length''){
}
if ($sort=='name'){
}
for($i=0; $i<$u;$i++)
{
echo "<tr>
<td>".$song[$i]["songNumber"]."</td>
<td>".$song[$i]["length"].".</td>
<td>".$song[$i]["name"]."</td> </tr>";
}
?>
</tbody>
</table>
MY QUESTION: How could i sort the table/array alphabetically or by length (its in seconds) (depending of the $sort variable)
Thanks for answering!!!!
I have already read the PHP documentation but I dont understand it / dont know how to apply it to my situation
<?php
$u=0
for($i=5; $i<$infoSource; $i=$i+2)
{
$song[$u]=array("songNumber"=>($u+1),
"length"=>$thisCD[$i],
"name"=>$thisCD[($i+1)]);
$u++;
}
?>
<table border=1>
<tbody>
<tr>
<th>Number</th>
<th>Length</th>
<th>Title</th>
</tr>
<?php
if ($tri=='num'){
}
if ($sort=='length''){
}
if ($sort=='name'){
}
for($i=0; $i<$u;$i++)
{
echo "<tr>
<td>".$song[$i]["songNumber"]."</td>
<td>".$song[$i]["length"].".</td>
<td>".$song[$i]["name"]."</td> </tr>";
}
?>
</tbody>
</table>
MY QUESTION: How could i sort the table/array alphabetically or by length (its in seconds) (depending of the $sort variable)
Thanks for answering!!!!
I have already read the PHP documentation but I dont understand it / dont know how to apply it to my situation