function element_children

cis7 element_children(&$elements, $sort = FALSE)
cle7 element_children(&$elements, $sort = FALSE)
elmsmedia7 element_children(&$elements, $sort = FALSE)
icor7 element_children(&$elements, $sort = FALSE)
meedjum_blog7 element_children(&$elements, $sort = FALSE)
mooc7 element_children(&$elements, $sort = FALSE)

Identifies the children of an element array, optionally sorted by weight.

The children of a element array are those key/value pairs whose key does not start with a '#'. See drupal_render() for details.


$elements: The element array whose children are to be identified.

$sort: Boolean to indicate whether the children should be sorted by weight.

Return value

The array keys of the element's children.

186 calls to element_children()
adaptivetheme_page_alter in sites/all/themes/ulmus/adaptivetheme/at_core/inc/
admin_menu_admin_menu_output_build in sites/all/modules/ulmus/admin_menu/admin_menu.module
Implements hook_admin_menu_output_build().
admin_menu_toolbar_admin_menu_output_alter in sites/all/modules/ulmus/admin_menu/admin_menu_toolbar/admin_menu_toolbar.module
Implements hook_admin_menu_output_alter().
advanced_help_form_system_modules_alter in sites/all/modules/ulmus/advanced_help/advanced_help.module
Implements hook_form_system_modules_alter().
alpha_calculate_position in sites/all/themes/ulmus/omega/alpha/includes/
Calculates the position of a element in a grid container by using the #weight as the DOM position and then calculation the required pull and push CSS classes to move the affected elements to their proper #position value.

... See full list


includes/, line 6413
Common functions that many Drupal modules will need to reference.


function element_children(&$elements, $sort = FALSE) {
  // Do not attempt to sort elements which have already been sorted.
  $sort = isset($elements['#sorted']) ? !$elements['#sorted'] : $sort;

  // Filter out properties from the element, leaving only children.
  $children = array();
  $sortable = FALSE;
  foreach ($elements as $key => $value) {
    if ($key === '' || $key[0] !== '#') {
      $children[$key] = $value;
      if (is_array($value) && isset($value['#weight'])) {
        $sortable = TRUE;
  // Sort the children if necessary.
  if ($sort && $sortable) {
    uasort($children, 'element_sort');
    // Put the sorted children back into $elements in the correct order, to
    // preserve sorting if the same element is passed through
    // element_children() twice.
    foreach ($children as $key => $child) {
      $elements[$key] = $child;
    $elements['#sorted'] = TRUE;

  return array_keys($children);