4.7.x form.inc element_children($element)
5.x common.inc element_children($element)
6.x common.inc element_children($element)
7.x common.inc element_children(&$elements, $sort = FALSE)

Get keys of a structured array tree element that are not properties (i.e., do not begin with '#').

1 call to element_children()
drupal_render in includes/common.inc
Renders HTML given a structured array tree.


includes/common.inc, line 3126
Common functions that many Drupal modules will need to reference.


function element_children($element) {
  return array_filter(array_keys((array) $element), 'element_child');


capellic’s picture

The idea in using element_children() is that I would haven't to go hunting down dead-end branches, thereby increasing performance?

mattcasey’s picture

This function comes in handy especially when looping through elements in forms. For example, a fieldset array will include array elements on the same level as string variables like #type, etc. that you don't want to affect.