时间:2021-07-01 10:21:17 帮助过:20人阅读
$a = Array
(
0 => 3,
1 => 1,
2 => 2,
3 => 7
);
$b = Array
(
1 => 'Emross War',
2 => 'Roman Empire',
3 => 'Avalon Wars',
7 => '掌上三国',
9 => '罗马(91)',
10 =>'Space Dominions',
11 =>'腾讯三国',
12 =>'Vampire War',
15 =>'三国英雄传',
17 =>'掌上水浒'
);
foreach($a as $k){
$c[$k]=$b[$k];
}
ksort($c);
print_r($c);
sort($a); // 将数组 $a 按值升序排列
$c = array(); //定义一个结果数组
foreach($a as $k) { // 依次从数组 $b 中取值
$c[$k] = $b[$k];
}
$a = Array
(
'0' => 3,
'1' => 1,
'2' => 2,
'3' => 7
);
$b = Array
(
'1' => 'Emross War',
'2' => 'Roman Empire',
'3' => 'Avalon Wars',
'7' => '掌上三国',
'9' => '罗马(91)',
'10' => 'Space Dominions',
'11' => '腾讯三国',
'12' => 'Vampire War',
'15' => '三国英雄传',
'17' => '掌上水浒',
);
$c = array_flip($a); //array_flip -- 交换数组中的键和值