是否有一种简单的方法来对具有用于此任务的可变数组的数组进行排序? 例如:PHP - 使用另一个阵列对数组进行排序
$fruits [
'Apple' => '12',
'Cherry' => '10',
'Lemon' => '34',
'Peach' => '6'
]
$order [
1 => 'Peach',
2 => 'Other',
3 => 'Lemon',
4 => 'Other2',
5 => 'Apple',
6 => 'Cherry',
7 => 'Other3'
]
我想退掉这类型的数组:
$ordered_fruits [
'Peach' => '6',
'Lemon' => '34',
'Apple' => '12',
'Cherry' => '10'
]
见阵列的这个例子结合功能可能会帮助 http://www.w3schools.com/php/showphp。 asp?filename = demo_func_array_combine –
没有排序,只是搜索并创建一个新阵列。 –