You are here

function _gmap_compress_array in GMap Module 7.2

Same name and namespace in other branches
  1. 5 gmap_markerinfo.inc \_gmap_compress_array()
  2. 6.2 gmap_markerinfo.inc \_gmap_compress_array()
  3. 6 gmap_markerinfo.inc \_gmap_compress_array()
  4. 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.
_gmap_get_icondata in ./gmap_markerinfo.inc
Get marker icon data for constructing json object.

File

./gmap_markerinfo.inc, line 240
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;
    }
  }
}