You are here

function _comment_alter_cleanup_arrays in Comment Alter 7

Same name and namespace in other branches
  1. 8 comment_alter.module \_comment_alter_cleanup_arrays()

Helper function to recursively clean up semi-empty arrays.

Eg. array('foo' => array('bar' => array('baz' => ''))) becomes array().

Parameters

array $a: Array whose empty elements should be removed.

1 call to _comment_alter_cleanup_arrays()
_comment_alter_cleanup_field_values in ./comment_alter.module
Helper function to clean up field values for comparison.

File

./comment_alter.module, line 307
Provides UI to alter nodes' parameters from comment forms.

Code

function _comment_alter_cleanup_arrays(&$a) {
  if (is_array($a)) {
    foreach ($a as $key => &$value) {
      if (is_array($value)) {
        _comment_alter_cleanup_arrays($value);
      }
      if (empty($value)) {
        unset($a[$key]);
      }
    }
  }
}