openlayers/includes/openlayers.form.inc, line 490
- Versions
- 6
_openlayers_unset_empty_values($array)
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
Code
<?php
function _openlayers_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_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;
}
?> 