ksort
(PHP3 , PHP4)
ksort --- 将数组的索引值排列
语法 : int ksort (array array [, int sort_flags] ) );
说明 :
此函数将数组依照索引值由a-z重新排列
Example :
$fruits = array("d" => "lemon" , "a" => "orange" , "b" => "banana" , "c" => "apple");
ksort($fruits);
for(reset($fruits) ; $key = key($fruits) ; next($fruits)) {
echo "fruits[$key] = " .$fruits[$key]. "\n";
}
此范例的结果为 :
fruits[a] = orange
fruits[b] = banana
fruits[c] = apple
fruits[d] = lemon
参考 : asort( ) arsort( ) sort( ) rsort( )