Get form element's label/value pairs from &$form or &$form_state I need to pass an array with all the fields (with their values) from a form from the submit function to a rules_invoke_event.

to do this I'm calling a get_fields() function, in this function I have acces to the form and form_state objects. Just wondering how I could loop through one of these with a foreach to get an array with the pairs?

function get_fields($form, $form_state)
  $fields = array()
  foreach(element in form)
  { 
    $fields[$element[key]] = element[value];
  }
  return$ fields
}


something like this but with correct syntax?

Help would be greatly appreciated :)
This might work.

function get_fields_this_step($form_state) {
    $fields = array();
    foreach($form_state['values'] as $key=&gt;$value){
        $fields[$key] = $value;
    }
    unset($value);
    return $fields;
}