Help me to understand what element_child() does
Suppose you have an array as the following (it's an array as accepted from the form API):

  $form['example_text'] = array(
    '#type' =&gt; 'textfield', 
    '#title' =&gt; t('Testing text'), 
    '#default_value' =&gt; '', 
    '#size' =&gt; 45, 
    '#maxlength' =&gt; 45, 
    '#required' =&gt; TRUE, 
    '#description' =&gt; t('This is an example form demonstrating forms usage in the installer profiles tasks. Enter any text to see what happens.'),
  );

  $form['continue'] = array(
    '#type' =&gt; 'submit', 
    '#value' =&gt; t('Continue'),
  );

  $form['errors'] = array();
  $form['#action'] = $url;
  $form['#redirect'] = FALSE;


If you execute element_children($form) will return an array containing the following indexes:


example_text
continue
errors


When $key is a string $key[0] is the first character of that string. The value of !isset($key[0]) || $key[0] != '#' is TRUE when the string $key is empty, or when the first character of that string is not #; array_filter() returns an array containing the keys and values for which the function referred as second argument returns TRUE.

The reason to do this is that, in the array used by the form API, keys starting with # are considered properties of that form field (or of the form), while keys that don't start with # are considered child of that form field; in the example code I used, '#redirect' is a property of the form, while 'example_text' is a form field that is child of the form.