You are here

function openlayers_merge_maps in Openlayers 6

Merge Maps

Recursive function to merge maps. PHP's array_merge_recursive creates unnecesary arrays to values if keys are the same. This function simply overwrites a value, even if the key is numeric.

Parameters

$map1: Map array that holds values that are not preferred

$map2: Map array that holds values that are preferred

Return value

map array

Related topics

2 calls to openlayers_merge_maps()
openlayers_presets_ui_presets_manage_add in modules/openlayers_presets_ui/includes/openlayers_presets_ui.ui.inc
Menu Callback for Add Preset
_openlayers_presets_ui_merge_maps in modules/openlayers_presets_ui/includes/openlayers_presets_ui.ui.inc
Merge maps from form and original preset

File

./openlayers.module, line 599
Main OpenLayers API File

Code

function openlayers_merge_maps($map1 = array(), $map2 = array()) {

  // Check maps
  if (is_array($map1) && is_array($map2)) {
    foreach ($map2 as $k => $v) {
      if (isset($map1[$k]) && is_array($v) && is_array($map1[$k])) {
        $map1[$k] = openlayers_merge_maps($map1[$k], $v);
      }
      else {
        $map1[$k] = $v;
      }
    }
  }
  return $map1;
}