title: Need to iterate through array to capture all rows - currently only saving the number in the [0] or first record
body: <p>I could use some help with storing an array. The process defined below is working and saving a record! It saves the record defined in the [0] column. If a zero is there, it saves record one, if a 1 is there it saves record two etc.</p>
  
  <p>Now I need to automate this so it will do that for <strong>EACH RECORD</strong> as it iterates through. Perhaps a second foreach statement to tie them together? Or a for loop with an integer variable? I have tried many combos and it is still not working.</p>
  
  <pre><code>//0 = feeobject row[]: to keyfield=&gt;val
              //Array ([0] =&gt; 0)
  
  foreach($AgencyFeesBasicArray['AgencyFeesGetInfoResult']['FeeObject'][0] as $key=&gt;$data ) {  
  
  
              $PaymentID = $AgencyFeesBasicArray['AgencyFeesGetInfoResult']['FeeObject'][0]['PaymentID'];
              $ClientID = $AgencyFeesBasicArray['AgencyFeesGetInfoResult']['FeeObject'][0]['ClientID'];
              $ClientName = $AgencyFeesBasicArray['AgencyFeesGetInfoResult']['FeeObject'][0]['ClientName'];
              $Account_ID = $AgencyFeesBasicArray['AgencyFeesGetInfoResult']['FeeObject'][0]['Account_ID'];
              $State = $AgencyFeesBasicArray['AgencyFeesGetInfoResult']['FeeObject'][0]['State'];  
              $PaymentDate = $AgencyFeesBasicArray['AgencyFeesGetInfoResult']['FeeObject'][0]['PaymentDate'];
              $Amount = $AgencyFeesBasicArray['AgencyFeesGetInfoResult']['FeeObject'][0]['Amount'];
              $CheckID = $AgencyFeesBasicArray['AgencyFeesGetInfoResult']['FeeObject'][0]['CheckID'];
              $CreditorName = $AgencyFeesBasicArray['AgencyFeesGetInfoResult']['FeeObject'][0]['CreditorName'];
              $DRC_ClientID = $AgencyFeesBasicArray['AgencyFeesGetInfoResult']['FeeObject'][0]['DRC_ClientID'];      
              $DRC_TransactionID = $AgencyFeesBasicArray['AgencyFeesGetInfoResult']['FeeObject'][0]['DRC_TransactionID'];
  
              $sql = "INSERT INTO  tblAgencyFees (PaymentID, ClientID, ClientName, Account_ID, State, PaymentDate, Amount, CheckID, CreditorName, DRC_ClientID, DRC_TransactionID) VALUES ('".$PaymentID."', '".$ClientID."', '".$ClientName."', '".$Account_ID."', '".$State."', '".$PaymentDate."', '".$Amount."', '".$CheckID."', '".$CreditorName."', '".$DRC_ClientID."', '".$DRC_TransactionID."')";
              mysqli_query($connection, $sql);
          }
        //}
      //}
  echo $sql;
  
  $res = mysqli_query($connection, $sql);
  If( !$res ) exit( mysqli_error($connection) );
  </code></pre>
  
  <p>The array:</p>
  
  <pre><code>Array ( 
      [AgencyFeesGetInfoResult] =&gt; Array ( 
          [FeeObject] =&gt; Array ( 
              [0] =&gt; Array ( 
                  [PaymentID] =&gt; 816 
                  [ClientID] =&gt; 1141 
                  [ClientName] =&gt; Ortega, Daniel 
                  [Account_ID] =&gt; 2222100000010717 
                  [State] =&gt; OK 
                  [PaymentDate] =&gt; 2019-07-31T00:00:00 
                  [Amount] =&gt; 8.0000 
                  [CheckID] =&gt; 10 
                  [CreditorName] =&gt; 0 
                  [DRC_ClientID] =&gt; 1195 
                  [DRC_TransactionID] =&gt; 
              ) 
              [1] =&gt; Array ( 
                  [PaymentID] =&gt; 817 
                  [ClientID] =&gt; 1141 
                  [ClientName] =&gt; Ortega, Daniel 
                  [Account_ID] =&gt; 2222100000010717 
                  [State] =&gt; OK 
                  [PaymentDate] =&gt; 2019-07-31T00:00:00 
                  [Amount] =&gt; 92.0000 
                  [CheckID] =&gt; 11 
                  [CreditorName] =&gt; MF 
                  [DRC_ClientID] =&gt; 1195 
                  [DRC_TransactionID] =&gt; 
              ) 
              [2] =&gt; Array ( 
                  [PaymentID] =&gt; 847 
                  [ClientID] =&gt; 1141
                  [ClientName] =&gt; Ortega, Daniel 
                  [Account_ID] =&gt; 2222100000010717 
                  [State] =&gt; OK 
                  [PaymentDate] =&gt; 2019-08-14T13:21:49.23 
                  [Amount] =&gt; 195.0000 
                  [CheckID] =&gt; 13 
                  [CreditorName] =&gt; MF 
                  [DRC_ClientID] =&gt; 1195 
                  [DRC_TransactionID] =&gt; 
              ) 
          ) 
      ) 
  )
  </code></pre>