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 ) ) Link to comment https://forums.phpfreaks.com/topic/139879-solved-usort-help/ 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); Link to comment https://forums.phpfreaks.com/topic/139879-solved-usort-help/#findComment-731842 Share on other sites More sharing options...
ballhogjoni Posted January 7, 2009 Author Share Posted January 7, 2009 Thanks Aaron, Your Awesome! Link to comment https://forums.phpfreaks.com/topic/139879-solved-usort-help/#findComment-731850 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.