You are here

function _getlocations_compress_array in Get Locations 7

Same name and namespace in other branches
  1. 6.2 getlocations.markerinfo.inc \_getlocations_compress_array()
  2. 6 getlocations.markerinfo.inc \_getlocations_compress_array()
  3. 7.2 getlocations.markerinfo.inc \_getlocations_compress_array()

Remove trailing duplicates from an array.

2 calls to _getlocations_compress_array()
_getlocations_compress_icon_def in ./getlocations.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.
_getlocations_get_icondata in ./getlocations.markerinfo.inc
Get marker icon data for constructing json object.

File

./getlocations.markerinfo.inc, line 211
getlocations.markerinfo.inc @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function _getlocations_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;
    }
  }
}