function _form_options_flatten

_form_options_flatten($array)

Iterates over an array and returns a flat array with duplicate keys removed.

This function also handles cases where objects are passed as array values.

Related topics

File

includes/form.inc, line 2682
Functions for form and batch generation and processing.

Code

function _form_options_flatten($array) {
  $return = &drupal_static(__FUNCTION__);

  foreach ($array as $key => $value) {
    if (is_object($value)) {
      _form_options_flatten($value->option);
    }
    elseif (is_array($value)) {
      _form_options_flatten($value);
    }
    else {
      $return[$key] = 1;
    }
  }

  return $return;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!form.inc/function/_form_options_flatten/7.x