I have a dynamic array of latitudes and longitudes, but I need to insert the count of identical values while eliminating the duplicates via PHP. So this...
Array (
[0] => Array (
[lat] => 40.7587979
[lon] => -73.9623427
)
[1] => Array (
[lat] => 39.8587028
[lon] => -84.277025
)
[2] => Array (
[lat] => 37.7647993
[lon] => -122.4629897
)
[3] => Array (
[lat] => 37.7647993
[lon] => -122.4629897
)
[4] => Array (
[lat] => 33.5125302
[lon] => -117.6860507
)
[5] => Array (
[lat] => 39.8587028
[lon] => -84.277025
)
)
...becomes this...
Array (
[0] => Array (
[lat] => 40.7587979
[lon] => -73.9623427
[count] => 1
)
[1] => Array (
[lat] => 39.8587028
[lon] => -84.277025
[count] => 2
)
[2] => Array (
[lat] => 37.7647993
[lon] => -122.4629897
[count] => 2
)
[3] => Array (
[lat] => 33.5125302
[lon] => -117.6860507
[count] => 1
)
)
I understand using array_count_values(), but that doesn't insert the new count values within each node. The use case would be a heatmap where the map is weighted based on the number of identical coordinates.