function _openlayers_presets_ui_unset_empty_values in Openlayers 6
Recursively unset empty values
Go through an array recursively and unset empty strings and arrays
Parameters
$values: Array
Return value
Array with empty values unset
2 calls to _openlayers_presets_ui_unset_empty_values()
- _openlayers_presets_ui_convert_form_to_map in modules/
openlayers_presets_ui/ includes/ openlayers_presets_ui.ui.inc - OpenLayers Form to Map
- _openlayers_presets_ui_merge_maps in modules/
openlayers_presets_ui/ includes/ openlayers_presets_ui.ui.inc - Merge maps from form and original preset
File
- modules/
openlayers_presets_ui/ includes/ openlayers_presets_ui.ui.inc, line 1053 - This file holds the functions for the openlayers presets ui
Code
function _openlayers_presets_ui_unset_empty_values($array) {
foreach ($array as $key => $value) {
// If it is an array then recursively check it
if (is_array($value)) {
$array[$key] = _openlayers_presets_ui_unset_empty_values($value);
}
// If it is an array then check if it is empty. We don't use $value so that if it
// is emptied by the previous check then it will still unset.
if (is_array($array[$key])) {
if (empty($array[$key])) {
unset($array[$key]);
}
}
// If it is an empty string then unset it
if ($value == "") {
unset($array[$key]);
}
}
return $array;
}