albertdumb Posted July 6, 2007 Share Posted July 6, 2007 Hi all, i need help to rearrange a multidimensional array. I have an array like this:> Array ( [1] => Array ( [dep_airport] => ACE [arr_airport] => BHX ) [2] => Array ( [dep_airport] => ACE [arr_airport] => LGW ) Now i want to sort this array into a new array so that, if a dep_airport has the same value - list all the arr_airport as a value and dep_airport as a key like so: array( [ACE] => Array ( [0]=>BHX [1]=>LGW ) Can someone please help??? Cheers Link to comment https://forums.phpfreaks.com/topic/58719-solved-sortre-arranging-a-multidimension-array/ Share on other sites More sharing options...
per1os Posted July 6, 2007 Share Posted July 6, 2007 <?php foreach ($dept_array as $array) { $new_array[$array['dep_airport']][] = $array['arr_airport']; } print_r($new_array); ?> See if that works for ya. Link to comment https://forums.phpfreaks.com/topic/58719-solved-sortre-arranging-a-multidimension-array/#findComment-291234 Share on other sites More sharing options...
albertdumb Posted July 6, 2007 Author Share Posted July 6, 2007 Cheers dude. See why you are a super Guru. Link to comment https://forums.phpfreaks.com/topic/58719-solved-sortre-arranging-a-multidimension-array/#findComment-291246 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.