Hello,
If I have an array structured like the following:
'0' ...
'0' ...
'1' ...
'2' ...
'1' ...
'0' => "Mike"
'1' => "1892"
'2' => "1"
'2' ...
'0' => "Paul"
'1' => "1672"
'2' => "1"
'3' ...
'0' => "Sam"
'1' => "1872"
'2' => "1"
'4' ...
'0' => "David"
'1' => "2090"
'2' => "1"
'5' ...
'0' => "Daniel"
'1' => "1652"
'2' => "1"
'6' ...
'0' => "Frank"
'1' => "2192"
'2' => "0"
'7' ...
'0' => "Louis"
'1' => "1892"
'2' => "1"
'8' ...
'0' => "Michael"
'1' => "1910"
'2' => "0"
Note: During actual usage, the actual array may be of any size and contain more or less objects than the example provide.
I would like to organize the array in two groups of arrays.
Group one will contain objects where the value of the 3rd key is equal to 0
Group two will contain objects where the value of the 3rd key is equal to 1
Essentially, it needs to look like this:
Group one
'0' ...
'0' => "Michael"
'1' => "1910"
'2' => "0"
'1' ...
'0' => "Frank"
'1' => "2192"
'2' => "0"
Group two:
'0' ...
'0' => "Louis"
'1' => "1892"
'2' => "1"
'1' ...
'0' => "Mike"
'1' => "1892"
'2' => "1"
'2' ...
'0' => "Paul"
'1' => "1672"
'2' => "1"
'3' ...
'0' => "Sam"
'1' => "1872"
'2' => "1"
'4' ...
'0' => "David"
'1' => "2090"
'2' => "1"
Now from group one, I would like to extract the object where the value of its key 1 is the greater of the group. for Group one, I will need to extract:
'1' ...
'0' => "Frank"
'1' => "2192"
'2' => "0"
For group two, I would like to extract the object where the value of its key 1 is also the greater of that group. For Group two, I will need to extract:
'4' ...
'0' => "David"
'1' => "2090"
'2' => "1"
I hope this makes some sense.
I appreciate any thoughts on this!
Thanks,
Mossa