如何从最小到最大对数组进行排序?
到目前为止,我只找到从最大到最少。
这是我当前的代码:
<?php
$person = Array ('100', '500', '200');
arsort($person, SORT_NUMERIC);
echo '<pre>' . print_r($person, true) . '</pre>';
?>
asort($person, SORT_NUMERIC);
Array
(
[0] => 100
[2] => 200
[1] => 500
)
澄清一下:arsort
实际上代表数组反向排序。所以相反有助于:)
使用:
<?php
$person = array ('100', '500', '200');
sort($person);
print_r($person);
?>