Skip to content

Instantly share code, notes, and snippets.

@benvds
Created January 25, 2010 13:03
Show Gist options
  • Save benvds/285849 to your computer and use it in GitHub Desktop.
Save benvds/285849 to your computer and use it in GitHub Desktop.
array_trim - trims given array recursively from empty values
// trims given array recursively from empty values
function array_trim($array) {
foreach ($array as $key => $value):
if(is_array($value)) {
$array[$key] = array_trim($value);
if(!count($array[$key])) unset($array[$key]);
} else {
if (empty($value)) unset($array[$key]);
}
endforeach;
return $array;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment