我想按键对关联数组进行排序。我使用 ksort 函数,但它返回 1 而不是数组。下面是我的代码。
$states=array( "DD"=>"Daman and Diu", "LD"=>"Lakshdweep", "DN"=>"Dadra
and nagar haveli", "AN"=>"Andaman and Nicobar island", "SK"=>"Sikkim",
"MZ"=>"Mizoram", "GA"=>"Goa", "PY"=>"Puduchery", "CH"=>"Chandigarh",
"ML"=>"Meghalaya", "AR"=>"Arunachal Pradesh", "TR"=>"Tripura",
"HP"=>"Himanchal Pradesh", "NL"=>"Nagaland", "PB"=>"Punjab",
"CG"=>"Chattisgarh", "JK"=>"Jammu and Kashmir", "UA"=>"Uttrakhand",
"HR"=>"Haryana", "JH"=>"Jharkhand", "KL"=>"Kerela", "MN"=>"Manipur" ,
"AS"=>"Assam", "RJ"=>"Rajasthan", "MP"=>"Madhya Pradesh",
"KA"=>"Karnataka", "BR"=>"Bihar", "OR"=>"Orissa", "GJ"=>"Gujrat",
"AP"=>"Andhra Pradesh", "TN"=>"TamilNadu", "DL"=>"Delhi",
"MH"=>"Maharastra", "WB"=>"WestBengal", "UP"=>"UttarPradesh",
);
$states = ksort($states);
print_r($states);
我得到的输出是:1
我想要数组而不是 1。