我在PHP中的數組:排序陣列上的任意鍵
$myarray[$index]['height']
$myarray[$index]['weight']
$myarray[$index]['age']
這是任何一個鍵「高度」,「重」或「年齡」的排序最好的功能?
一個例子,如果我在輸入
$myarray[0]['height'] = 175;
$myarray[0]['weight'] = 68;
$myarray[0]['age'] = 44;
$myarray[1]['height'] = 166;
$myarray[1]['weight'] = 82;
$myarray[1]['age'] = 56;
$myarray[2]['height'] = 188;
$myarray[2]['weight'] = 82;
$myarray[2]['age'] = 35;
,我想按年齡排序,我獲得
$myarray[0]['height'] = 188;
$myarray[0]['weight'] = 82;
$myarray[0]['age'] = 35;
$myarray[1]['height'] = 175;
$myarray[1]['weight'] = 68;
$myarray[1]['age'] = 44;
$myarray[2]['height'] = 166;
$myarray[2]['weight'] = 82;
$myarray[2]['age'] = 56;
[usort()](http://php.net/manual/en/function.usort.php)將您想要排序的列傳遞給回調 –