Sort multi-dimensional array by specific key

后端 未结 5 2111
你的背包
你的背包 2020-11-28 15:51

I have an array:

Array (
    [0] => stdClass Object (
        [user_id] => 1
        [ID] => 1
        [user_login] => admin
        [display_nam         


        
5条回答
  •  萌比男神i
    2020-11-28 16:20

    Take a look at following article. It does describe how to use usort() and also describes how to use create_function() so that you can use single function to sort on different fields (with required direction asc or desc).

    http://phpave.com/sorting-associative-array-specific-key/

提交回复
热议问题