簡體   English   中英

我如何排序數組

[英]How can I sort an array

我有這個數組

Array (  
 [146] => Post Object ( 
 [ID] => 5664  
 [post_author] => 8  
 [post_date] => 2016-04-10 16:21:55  
 [post_content] =>
 )  

 [145] => Post Object (  
 [ID] => 5638  
 [post_author] => 7  
 [post_date] => 2016-03-17 12:23:00  
 [post_content] =>
 )
) 

我想通過“ => Post Object”之前的數字對數組進行排序。

即我希望子數組145出現在146之前。

謝謝

您可以使用kso​​rt函數。

ksort($array);

對於其他行為,請閱讀http://php.net/manual/en/array.sorting.php上的相關文檔。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM