What is the best method to preserve the order of an array while placing duplicate values in order.
Here is the array:
Array
(
[0] => Array
(
[location] => 1320 N Street
)
[1] => Array
(
[location] => 1316 N St
)
[2] => Array
(
[location] => 1320 N Street
)
)
I would like to group duplicate locations so it looks like this:
Array
(
[0] => Array
(
[location] => 1320 N Street
)
[1] => Array
(
[location] => 1320 N Street
)
[2] => Array
(
[location] => 1316 N St
)
)
My initial thought was to loop through the array and perform an array_search on the location key to get the index a duplicate location, then perform a shift to move the location.
Thanks for your time.