function _gmap_compress_array in GMap Module 6.2
Same name and namespace in other branches
- 5 gmap_markerinfo.inc \_gmap_compress_array()
- 6 gmap_markerinfo.inc \_gmap_compress_array()
- 7.2 gmap_markerinfo.inc \_gmap_compress_array()
- 7 gmap_markerinfo.inc \_gmap_compress_array()
Remove trailing duplicates from an array.
2 calls to _gmap_compress_array()
- _gmap_compress_icon_def in ./
gmap_markerinfo.inc - Make a compressed definition. A series of arrays with trailing holes allowed. Any missing values at the end of subarrays are equal to the last defined value.
- _gmap_get_icondata in ./
gmap_markerinfo.inc - Get marker icon data for constructing json object.
File
- ./
gmap_markerinfo.inc, line 209 - GMap marker information routines.
Code
function _gmap_compress_array(&$arr) {
if (empty($arr)) {
return;
}
$c = count($arr) - 1;
// Walk backwards and unset duplicates...
for ($cval = $arr[$c]; $c > 0; $c--) {
if ($arr[$c - 1] == $cval) {
unset($arr[$c]);
}
else {
// .. until we hit a different number.
break;
}
}
}