Happy New Year Experts!
I hope this question finds you all well and ready for a fantastic new year.
I'd like to start out simple this year (simple at least to you PHP geniuses out there.)
I have a multidimentional associative array, let's call it $A. This array can be accessed by using two keys such as $A[$key1][$key2].
Right now, the order of the elements goes something like this:
$A['first']['e1']
$A['first']['e2']
$A['first']['e3']
$A['first']['e4']
$A['first']['e5']
$A['first']['e6']
$A['second']['e1']
$A['second']['e2']
$A['second']['e3']
$A['second']['e4']
$A['second']['e5']
$A['second']['e6']
$A['third']['e1']
$A['third']['e2']
$A['third']['e3']
$A['third']['e4']
$A['third']['e5']
$A['third']['e6']
...etc.
I would like to create a new array grouping all the "e1" elements together, then the "e2" elements and so on, so that the new array would look something like the following:
$NewArray['e1'] = array($A['first']['e1'], $A['second']['e1'], $A['third']['e1'], etc...);
$NewArray['e2'] = array($A['first']['e2'], $A['second']['e2'], $A['third']['e2'], etc...);
$NewArray['e3'] = array($A['first']['e3'], $A['second']['e3'], $A['third']['e3'], etc...);
etc...
What is the simplest, most elegant and efficient solution to this?
Thanks!