Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次のような配列があります。
Array( [31] => 1 [30] => 2 [29] => 3 [28] => 4 )
次に、ksort($array)28、29、30、および 31 としてソートするものを使用しますが、これの問題は、1 ~ 4 の数字が値と一緒に表示されるため、逆になることです。28 を 1 にしたい、29 を 2 にしたいなど。
ksort($array)
foreach ループを作成せずに新しい配列を再構築してこの切り替えを行う方法はありますか?