Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否有按 desc 顺序按值(而不是按键)排序数组的函数?以下是要排序的数组。
array( 0 => 3223, 1 => 675, 2 => 56, 3 => 66899, )
asort()并且arsort()会这样做。
asort()
arsort()
http://www.php.net/manual/en/function.asort.php
请试试这个
<?php $fruits = array("lemon", "orange", "banana", "apple"); rsort($fruits); foreach ($fruits as $key => $val) { echo "$key = $val\n"; } ?>
我希望它会帮助你
另请参阅http://php.net/manual/en/function.rsort.php