Advertisement
chrishajer

Loop through complex multi-inputs like address

Sep 3rd, 2013
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.65 KB | None | 0 0
  1. <?php
  2. // loop through complex multi inputs like address, name and checkboxes
  3. // Help Scout 29847
  4. // http://pastie.org/8295603
  5. $values= array();
  6.  
  7. foreach( $form['fields'] as $field ) {
  8.  
  9.     if(isset($field["inputs"])){
  10.         $input_value = array();
  11.         foreach($field["inputs"] as $input){
  12.             $input_value[] = $lead[$input["id"]];
  13.         }
  14.         $field_value = implode(" ", $input_value);
  15.     }
  16.     else{
  17.         $field_value = $lead[ $field['id'] ];
  18.     }
  19.  
  20.     $values[$field['id']] = array(
  21.         'id' => $field['id'],
  22.         'label' => $field['label'],
  23.         'value' => $field_value
  24.     );
  25.  
  26.  
  27. }
  28. print_r($values)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement