在下表中,$count1
是一个数字值。如何按$count1
降序对表格进行排序?按数组结果排序表
$words = explode(" ", $commentstring);
$result = array_combine($words, array_fill(0, count($words), 0));
foreach($words as $word) {
$result[$word]++;
}
echo "<table>";
foreach($result as $word => $count1) {
echo '<tr>';
echo '<td>';
echo "$word";
echo '</td>';
echo '<td>';
echo "$count1 ";
echo '</td>';
echo '</tr>';
}
echo "</table>";
你在寻找['asort()'](http://us.php.net/manual/en/function.asort.php)? – 2012-02-03 00:43:52
使用'asort()'按降序排列,'arsort()'按升序排列 – 2012-02-03 00:49:09
我在哪里放置'asort()'? – John 2012-02-03 01:10:56