i am trying to return a "altered" array.
for example my current array looks like this: The Code:
$filtered = array();
foreach($inBounds as $index => $columns) {
foreach($columns as $key => $value) {
if(in_array($columns,$filtered)){
}else{
$filtered[$z] = $columns;
$z = $z + 1;
}
}
}
The Array
Array
(
[141] => Array
(
[id] => 1006
[lat] => 51.28940600
[lng] => 6.98730500
[name] => fghfgh
[date] => 2018-08-31 11:47:23
[sizeIcon] => icon1
[limit_lat] => 51
[count] =>
)
[142] => Array
(
[id] => 1007
[lat] => 51.29198200
[lng] => 6.97700500
[name] => asdasd
[date] => 2018-08-31 13:55:11
[sizeIcon] => icon1
[limit_lat] => 51
[count] =>
)
[143] => Array
(
[id] => 1008
[lat] => 51.27308500
[lng] => 6.97563200
[name] => adasdsad
[date] => 2018-08-31 13:55:16
[sizeIcon] => icon1
[limit_lat] => 51
[count] =>
)
[144] => Array
(
[id] => 1009
[lat] => 51.97811300
[lng] => 7.83325200
[name] => wer
[date] => 2018-08-31 13:56:02
[sizeIcon] => icon1
[limit_lat] => 52
[count] =>
)
[145] => Array
(
[id] => 1010
[lat] => 51.92394300
[lng] => 8.60229500
[name] => werwer
[date] => 2018-08-31 13:56:07
[sizeIcon] => icon1
[limit_lat] => 52
[count] =>
)
[146] => Array
(
[id] => 1011
[lat] => 27.95195200
[lng] => -82.46612500
[name] => sdfsdf
[date] => 2018-08-31 13:57:12
[sizeIcon] => icon1
[limit_lat] => 28
[count] =>
)
[147] => Array
(
[id] => 1012
[lat] => 27.94588600
[lng] => -82.42080700
[name] => sdfsdfsdf
[date] => 2018-08-31 13:57:16
[sizeIcon] => icon1
[limit_lat] => 28
[count] =>
)
[148] => Array
(
[id] => 1013
[lat] => 28.00773900
[lng] => -82.48672500
[name] => werwerwer
[date] => 2018-08-31 13:57:20
[sizeIcon] => icon1
[limit_lat] => 28
[count] =>
)
[149] => Array
(
[id] => 1014
[lat] => 28.11438300
[lng] => -82.43454000
[name] => bvbvbvb
[date] => 2018-08-31 13:57:31
[sizeIcon] => icon1
[limit_lat] => 28
[count] =>
)
[140] => Array
(
[id] => 1005
[lat] => 49.48240100
[lng] => 0.28564500
[name] => dsfsdf
[date] => 2018-08-30 15:21:32
[sizeIcon] => icon1
[limit_lat] => 49
[count] =>
)
)
Now i want to count the duplicates ( [limit_lat] ), remove them from the current array and put them back together like the following array:
this is what i need it to look like after the duplicate purge.
Array
(
[0] => Array
(
[id] => 1006
[lat] => 51.28940600
[lng] => 6.98730500
[name] => fghfgh
[date] => 2018-08-31 11:47:23
[sizeIcon] => icon1
[limit_lat] => 51
[count] => 3
)
[1] => Array
(
[id] => 1009
[lat] => 51.97811300
[lng] => 7.83325200
[name] => wer
[date] => 2018-08-31 13:56:02
[sizeIcon] => icon1
[limit_lat] => 52
[count] => 2
)
[2] => Array
(
[id] => 1011
[lat] => 27.95195200
[lng] => -82.46612500
[name] => sdfsdf
[date] => 2018-08-31 13:57:12
[sizeIcon] => icon1
[limit_lat] => 28
[count] => 4
)
[3] => Array
(
[id] => 1005
[lat] => 49.48240100
[lng] => 0.28564500
[name] => dsfsdf
[date] => 2018-08-30 15:21:32
[sizeIcon] => icon1
[limit_lat] => 49
[count] => 1
)
)
right now i am able to count them nicely but i am only getting this back: The Code:
$data = array();
foreach($filtered as $cluster) {
if(isset($data[$cluster['limit_lat']])) {
$data[$cluster['limit_lat']]++;
} else {
$data[$cluster['limit_lat']] = 1;
}
}
The Array:
Array
(
[51] => 3
[52] => 2
[28] => 4
[49] => 1
)
I already tried multiple approaches but not with the wanted result. Someone has an idea how i can get this working?
Thanks, Dennis