asort()
保留键后如何将元素添加到开始数组?
$array = array(
564 => "plum",
123 => "apple",
543 => "lemon",
321 => "cherry",
);
asort($array);
$array[0]="all";
print_r($array);
我明白了,键 [0] 的索引不在开头
Array(
[123] => apple
[321] => cherry
[543] => lemon
[564] => plum
[0] => all )
需要
Array(
[0] => all
[123] => apple
[321] => cherry
[543] => lemon
[564] => plum)