openlayers/openlayers.module, line 354
- Versions
- 6
openlayers_merge_maps($map1 = array(), $map2 = array())
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
Code
<?php
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;
}
?> 