ballhogjoni Posted January 7, 2009 Share Posted January 7, 2009 I want to sort a multi array but don't know how to do it. I read the manual, but it seems pretty complex. In the example below, I want to sort the array by the name. So the array should look like the second example I have. Array ( [0] => Array ( [id] => 1386 [name] => c [date_started] => 2006-07-24 12:51:16 ) [1] => Array ( [id] => 1849 [name] => d [date_started] => 2007-01-04 10:02:21 ) [2] => Array ( [id] => 4857 [name] => a [date_started] => 2008-08-22 14:42:35 ) ) Array ( [0] => Array ( [id] => 4857 [name] => a [date_started] => 2008-08-22 14:42:35 ) [1] => Array ( [id] => 1386 [name] => c [date_started] => 2006-07-24 12:51:16 ) [2] => Array ( [id] => 1849 [name] => d [date_started] => 2007-01-04 10:02:21 ) ) Quote Link to comment Share on other sites More sharing options...
rhodesa Posted January 7, 2009 Share Posted January 7, 2009 $array; //This is the array you give in your example $sort = array(); foreach($array as $item) $sort[] = $item['name']; array_multisort($sort,$array); print_r($array); Quote Link to comment Share on other sites More sharing options...
ballhogjoni Posted January 7, 2009 Author Share Posted January 7, 2009 Thanks Aaron, Your Awesome! 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.