這是我的多排序代碼。陣列內的多排序
但是,我怎麼能爲個人coloumns
是我迄今所做的做到這一點是
PHP代碼:
<?php
$a1=array("Cat","Alpha","two");
$a1=array("Cat","Beta","two");
$a1=array("Pluto","Beta","two");
$a1=array("Pluto","Alpha","two");
array_multisort($a1[0], SORT_ASC, SORT_STRING, $a1[1], SORT_NUMERIC, SORT_DESC);
$json[] = $a1;
$final=array("response"=>$a1);
echo json_encode($final);
?>
它會顯示爲
Array ([0] => Cat [1] => Dog [2] => zb) Array ([0] => Missy [1] => Pluto [2] => Fido)
我想顯示
的$首先Coloumn a1作爲ASC,那麼$二Coloumn a1作爲說明,
這樣的結果應該是
Col A Col B, Col C
Cat, Alpha two
Cat, Beta two
Pluto, Alpha two
Plugo, Beta two
我可怎麼辦呢?
做出更有益的陣列結構,像'陣列(陣列(「類型」 =>「狗」 ,'name'=>'Pluto'),...)',然後參見http://stackoverflow.com/q/17364127/476。 – deceze 2014-09-30 11:10:18
感謝您的鏈接,但在那array_multisort我找不到足夠的鍛鍊:( – 2014-09-30 11:51:55