title: increment variable AFTER each foreach loop
body: <p>I have a for each loop for importing some csv data. i need to increase $i after the whole loop runs on each ROW of the data. </p>
  
  <p>Data going, simple  9 columns and the test file is only 2 rows, but the prod file is 500 rows</p>
  
  <pre><code>ID,LastName,FirstName,Add1,City,State,__ZipCode__,Phone,Email
  11,lastnamevalue,firstnamevalue,addressvalue,cityvalue,MA,zip,6phone,email value
  11,lastnamevalue2,firstnamevalue2,addressvalue2,cityvalue2,MA,zip2,6phone2,email value2
  </code></pre>
  
  <p>Loop info</p>
  
  <pre><code>$i=0; 
  foreach ( $meta as $key =&gt; $value) {
  
       // If custom filed name is "textfield"
      if ($key == 'FirstName') {
          $meta_array[0]['members_'.$i.'_first_name'] = $value;
          $meta_array[1]['_members_'.$i.'_first_name'] = 'field_53eac4161a811';
  
      } elseif ($key == 'LastName') {
          $meta_array[0]['members_'.$i.'_last_name'] = $value;
          $meta_array[1]['_members_'.$i.'_last_name'] = 'field_53eac4291a812';
  
      } elseif ($key == 'Add1') {
          $meta_array[0]['members_'.$i.'_street'] = $value;
          $meta_array[1]['_members_'.$i.'_street'] = 'field_53eb96fc5d7da';
  
      } elseif ($key == 'City') {
          $meta_array[0]['members_'.$i.'_city'] = $value;
          $meta_array[1]['_members_'.$i.'_city'] = 'field_53eb97335d7dc';
  
      } elseif ($key == 'State') {
          $meta_array[0]['members_'.$i.'_state'] = $value;
          $meta_array[1]['_members_'.$i.'_state'] = 'field_5421e190161b0';
  
      } elseif ($key == '__ZipCode__') {
          $meta_array[0]['members_'.$i.'_zip_code'] = $value;
          $meta_array[1]['_members_'.$i.'_zip_code'] = 'field_5421e1acc0d65';
  
      } elseif ($key == 'Phone') {
          $meta_array[0]['members_'.$i.'_phone'] = $value;
          $meta_array[1]['_members_'.$i.'_phone'] = 'field_53ebb3419d355';
  
      } elseif ($key == 'Email') {
          $meta_array[0]['members_'.$i.'_email'] = $value;
          $meta_array[1]['_members_'.$i.'_email'] = 'field_5421e1b4c0d66';
  
      // Create array data to import to the Repeater Field
      }  else {
          $meta_array[$key] = $value;
      }
  
  }
  </code></pre>
  
  <p>So i need $i to equal 0 fore each of those else if statements and then when it gets to the last email one, it needs to increase to 1 and stay 1 for each of the else if's again, until the last one and then increase to 2.. so on and so forth...</p>
  
  <p>i think i need to count the else if or something, but i am terrible with loops and i can either get it to always be 0 or increase by 1 throughout every line so it ends up being firstname 1 firstname 2 etc.</p>
  
  <p>UPDATE:  its for a wordpress plugin that imports csv data... the csv is set up as firstname lastname blah blah...   each value gets set as its actual value and then anotehr one gets set with that "field_53eac4161a811" or whatever each one its... so each elseif inputs two rows into the database. which is working fine..(the array comes out as all teh info matched up but the $i is either always 0 or increments for each key/value instead of only once per loop) . except it is overwriting the previous one because the $i variable is the only marker that changes for each csv row of data... not sure if that helps explain it at all.</p>
  
  <p>below is what should come out... and it does, except when the file parses the next line of teh csv data it also come out with 0 0 0 0 0 0 instead of 1 1 1 1 1 1</p>
  
  <pre><code>    Array
      (
      [0] =&gt; Array
      (
          [members_0_last_name] =&gt; name value
          [members_0_first_name] =&gt; first name value
          [members_0_street] =&gt; street value
          [members_0_city] =&gt; city value
          [members_0_state] =&gt; state
          [members_0_zip_code] =&gt; zip
          [members_0_phone] =&gt; phone
          [members_0_email] =&gt; email
      )
  
  [1] =&gt; Array
      (
          [_members_0_last_name] =&gt; field_53eac4291a812
          [_members_0_first_name] =&gt; field_53eac4161a811
          [_members_0_street] =&gt; field_53eb96fc5d7da
          [_members_0_city] =&gt; field_53eb97335d7dc
          [_members_0_state] =&gt; field_5421e190161b0
          [_members_0_zip_code] =&gt; field_5421e1acc0d65
          [_members_0_phone] =&gt; field_53ebb3419d355
          [_members_0_email] =&gt; field_5421e1b4c0d66
      )
  
  [field_53eac3eb1a810] =&gt; Array
      (
      )
  
  )
  </code></pre>