_form_options_flatten

  1. drupal
    1. 8
    2. 7
Versions
7 – 8 _form_options_flatten($array)

Helper function for form_options_flatten().

Iterates over arrays which may share common values and produces a flat array that has removed duplicate keys. Also handles cases where objects are passed as array values.

Related topics

▾ 2 functions call _form_options_flatten()

form_options_flatten in includes/form.inc
Allows PHP array processing of multiple select options with the same value.
_form_options_flatten in includes/form.inc
Helper function for form_options_flatten().

Code

includes/form.inc, line 2463

<?php
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;
}
?>