PHP数组排序及重置键值
PHP数组执行排序后,用sort()或rsort()可以重置键值角标,其他只能排序不能重置键值角标
1 2 3 4 5 | <?php
$cars = array ( "Volvo" , "BMW" , "Toyota" );
sort( $cars );
print_r( $cars );
?>
|
sort() - 对数组进行升序排列
rsort() - 对数组进行降序排列
asort() - 根据关联数组的值,对数组进行升序排列
ksort() - 根据关联数组的键,对数组进行升序排列
arsort() - 根据关联数组的值,对数组进行降序排列
krsort() - 根据关联数组的键,对数组进行降序排列