现在我有两个数组 - $totaltimeplayed
和$gameslist
,其中$totaltimeplayed
中的每个值都指的是在$gameslist
中玩相应游戏所花费的时间。我想在$totaltimeplayed
中对游戏时间进行排序,然后根据$gameslist
对游戏进行排序。
到目前为止我的代码:
arsort($totaltimeplayed);
$key_order = array_keys($totaltimeplayed);
$sort_games = array_combine($key_order, $gameslist);
ksort($sort_games);
当我使用print_r()
时,似乎$ gameslist的排序是任意的,没有特别的顺序。
有什么问题?