How to filter the values of an array in drupal
This is an old question, but there didn't seem to be a decent answer yet...

There is no out-of-the-box solution but it's easy to write a function that recursively walks the array and applies a filter function to the keys and values.

&lt;?php
function clean_array($array, $filter = 'check_plain') {
  $clean = array();
  foreach ($array as $key =&gt; $val) {
    if (is_array($val)) {
      $clean[$filter($key)] = clean_array($val, $filter);
    }
    else {
      $clean[$filter($key)] = $filter($val);
    }
  }
  return $clean;
}
?&gt;


This also gives you the flexibility to use filter_xss or check_markup instead.

Hope that helps.