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 Quote Link to comment 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. Quote Link to comment 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. 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.