我有一个多维数组和另一个数组。我需要用另一个数组值对多维数组进行排序。
Array([0] => 7[1] => 6 [2] => 5[3] => 4)
使用上面的数组值需要通过此值[Outlets] [id]对下面的数组进行排序。两个数组只需要使用数组的值。 multiarray应该像这样排序ie ..([Outlets] [id] => 7,[Outlets] [id] => 6,[Outlets] [id] => 5,[Outlets] [id] = > 4)
Array
( [0] => Array
(
[Outlets] => Array
( [id] => 4
[name] => Chef Bakers, Bellandur
[image] => chefbakers.jpg
[partner_categories_id] => 5
)
[Localities] => Array
([name] => Bellandur Gate (Nr Total Mall))
)
[1] => Array
(
[Outlets] => Array
( [id] => 7
[name] => Homechefs - Rajasthani breakfast, Sarjapur
[image] => 1413881493hoechefs.jpg
[partner_categories_id] => 4
)
[Localities] => Array
([name] => Iblur Jn (Near Suncity))
)
[3] => Array
( [Outlets] => Array
( [id] => 6
[name] => Meat Mart, Sarjapur
[image] => 1414651527meatmart.jpg
[partner_categories_id] => 3
)
[Localities] => Array([name] => Bellandur Gate (Nr Total Mall))
)
[4] => Array
( [Outlets] => Array
( [id] => 5
[name] => Veggiez, Sarjapur
[image] => 1413881741veg.jpg
[partner_categories_id] => 6
)
[Localities] => Array([name] => Iblur Jn (Near Suncity))
)
)
你能帮帮忙吗?
我在这里没见过同样的问题。
ps:抱歉我的英文不好
我已修好:
$s=$sortvalue_array;
$res=$Multidimentional_array;
$new=array();
foreach($res as $r)
{
$a=array_search($r['Outlets']['id'],$s);
$new[$a]=$r;
}
ksort($new);
print_r($new);