I have a two-dimensional array I'd like to restructure. The "values" field are different 'votes' for how a listing should be named, "distance" is how far away the voter is from that location, "time" is when the vote took place, and "count" is based off the counts for corresponding unique "values".
I'd like to make "values" unique, only keep the "distance", "time" and "count" values that correspond to the first time a unique value was created, and reorganize the index.
Turn something like this:
$array = Array
(
[values] => Array
(
[0] => San Diego Zoo
[1] => San Diego Zoo
[2] => SD Zoo
)
[distance] => Array
(
[0] => 5
[1] => 350
[2] => 21
)
[time] => Array
(
[0] => 2014-02-03 08:57:29
[1] => 2014-02-03 08:57:54
[2] => 2014-02-03 08:58:12
)
[count] => Array
(
[0] => 2
[1] => 2
[2] => 1
)
)
Into this:
$array = Array
(
[values] => Array
(
[0] => San Diego Zoo
[1] => SD Zoo
)
[distance] => Array
(
[0] => 5
[1] => 21
)
[time] => Array
(
[0] => 2014-02-03 08:57:29
[1] => 2014-02-03 08:58:12
)
[count] => Array
(
[0] => 2
[1] => 1
)
)
I'm not sure how best to do this. I'm thinking to use array_unique on "values" ($array["values"]=array_unique($array["values"]);) but I wouldn't know how to remove the appropriate "distance", "time", and "count" values.