我有兩個關聯數組重新排序關聯數組基於參考關聯數組
$reference = array(
'type_drink' => 'value',
'type_plate' => 'value',
'type_fork' => 'value',
'non_type' => 'value'
);
$target = array(
'type_plate' => 'value other',
'type_drink' => 'value other'
);
什麼是一個很好的方式重新排序目標相匹配的密鑰的$參考訂單,而忽略鍵不存在於$目標,以使最終
$target = array(
'type_drink' => 'value other',
'type_plate' => 'value other'
);
我會說'array_intersect_key($ target,$ reference)',但後來我發現你想要數組排序。 –