Johnny2 Posted July 28, 2013 Report Share Posted July 28, 2013 I have this multidimensional array that I'll call "$Items_Array": array (size=3) 0 => array (size=3) 'id' => string '1' (length=1) 'quantity' => int 1 'name' => string 'Book' (length=1) 1 => array (size=3) 'id' => string '2' (length=1) 'quantity' => int 5 'name' => string 'Shirt' (length=29) 2 => array (size=3) 'id' => string '3' (length=1) 'quantity' => int 2 'name' => string 'Ice-cream' (length=22) I want to re-arrange the order of elements, according to "quantity", so that the one with the largest quantity comes first. The desired result would look like this: array (size=3) 0 => array (size=3) 'id' => string '2' (length=1) 'quantity' => int 5 'name' => string 'Shirt' (length=29) 1 => array (size=3) 'id' => string '3' (length=1) 'quantity' => int 2 'name' => string 'Ice-cream' (length=22) 2 => array (size=3) 'id' => string '1' (length=1) 'quantity' => int 1 'name' => string 'Book' (length=1) Can someone show me how to do this? Is it just an easy PHP command? Quote Link to comment Share on other sites More sharing options...
falkencreative Posted July 29, 2013 Report Share Posted July 29, 2013 Searching for "sort array of arrays php" may help. Here are a couple results: http://php.net/manual/en/array.sorting.php http://php.net/manual/en/function.array-multisort.php http://www.the-art-of-web.com/php/sortarray/#.Ufbx3WRgarg Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.