title: preview next array element using foreach
body: <p>I have a foreach that iterates between items in a array to build an excel file.
  I want to place a total row after each item in the array if the next element in the array matches a specific condition (has a specific value in one key).
  So I want to use <code>next()</code> to check that value but as far as I know and for what I read <a href="https://stackoverflow.com/questions/17962702/using-next-in-foreach-loop">here</a> using next I'll move the pointer to the next row and the answer was to use current. How can I see the next item in the array without moving the pointer? reading that question I have written this:</p>
  <pre><code>foreach($creds as $cred){
      echo $cred['tipo'];
      //if the next item has a 'tipo' key with a specific value
      if(current($creds['tipo'])!='4'){
          echo 'Total';
      }
  }
  </code></pre>
  <p>but this is not working. How to fix it?</p>
  <p><strong>EDIT: based on the answers I will move the echo 'Total' stuff at the beginning of the next iteration instead of at the bottom of the current iteration. There are no other solutions using foreach as far as I see in the answers</strong></p>