1
$employeeAges = array();
$employeeAges["Lisa"] = "28";
$employeeAges["Jack"] = "16";
$employeeAges["Ryan"] = "35";
$employeeAges["Rachel"] = "46";
$employeeAges["Grace"] = "34";
sort($employeeAges);
foreach($employeeAges as $name => $age){
echo "Name: $name, Age: $age <br />";
}
當我的$ employeeAges它打印出這個排序,沒有姓名的員工排序PHP中的數組
Name: 0, Age: 16
Name: 1, Age: 28
Name: 2, Age: 34
Name: 3, Age: 35
Name: 4, Age: 46
我將如何得到它打印出來的名字呢?我不知道它爲什麼會改變:S
簡單'asort' http://php.net/asort – cmorrissey
cmorrissey解決了它!謝謝,完全忘記了asort! – user3364498
歡迎來到Stack Overflow。請在查詢之前確保搜索。 – Boaz