I have a two-dimensional array in PHP that contains a city, it's state, and the population. If I build it like this:
$cities = array (
array("New York", "NY", 8008278),
array("Los Angeles", "CA", 3694820),
array("Chicago", "IL", 2896016),
array("Houston", "TX", 1953631),
array("Philadelphia", "PA", 1517550),
array("Phoenix", "AZ", 1321045),
array("San Diego", "CA", 1223400),
array("Dallas", "TX", 1188580),
array("San Antonio", "TX", 1144646),
array("Detroit", "MI", 951270)
);
How can I sort by the population (3rd row) in descending order? Here is some code to output the data in a table.
echo "<table>";
for ($row = 0; $row < 10; $row++) {
echo "<tr>";
for ($col = 0; $col < 3; $col++) {
echo "<td>".$cities[$row][$col]."</td>";
}
echo "</tr>";
}
echo "</table>";