我想把“for”函数的降序结果。 示例:我有这个 PHP 代码:
<?php
$field[1] = "Field 1"; // 1
$field[2] = "Field 2"; // 2
$field[3] = "Field 3"; // 3
$field[4] = "Field 4"; // 4
$field[5] = "Field 5"; // 5
$field[6] = "Field 6"; // 6
$field[7] = "Field 7"; // 7
$field[8] = "Field 8"; // 8
$field[9] = "Field 9"; // 9
$field[10] = "Field 10"; // 10
$i = "10";
for ($n=1 ; $n < $i ; $n++ ) {
echo $field[$n];
}
?>
将显示:
Field 1
Field 2
Field 3
Field 4
Field 5
Field 6
Field 7
Field 8
Field 9
Field 10
我该怎么做才能显示降序?像这样:
Field 10
Field 9
Field 8
Field 7
Field 6
Field 5
Field 4
Field 3
Field 2
Field 1
有什么解决办法吗?提前致谢!