開始我需要搜索這個數組:PHP搜索多維數組的值,然後將這個元素在陣列
cars -
[0] -make : Ford
-model: Escort
-year: 1991
[1] -make: Honda
-model: Civic
-year: 1996
[2] -make: Vauxhall
-model: Astra
-year: 1972
如果(例如)的模式是「公民」,地方「車」在位置0
所以端陣列將是這樣的:
cars -
[0] -make: Honda
-model: Civic
-year: 1996
[1] -make : Ford
-model: Escort
-year: 1991
[2] -make: Vauxhall
-model: Astra
-year: 1972
我已經嘗試了一些usort變化:
function typeSort($a, $b)
{
if ($a['model'] == 'Civic')
{
return 0;
}
return ($a['model'] < $b['model']) ? -1 : 1;
}
但這只是返回1