title: How do I know the last iteration of for loop?
body: <p>I have a <code>for</code> loop in my code:</p>
  
  <pre><code>$d = count( $v2['field_titles'] );
  
  for( $i=0; $i &lt; $d; $i++ ) {
    $current = 3 + $i;
    echo 'current is' . $current;
  }
  </code></pre>
  
  <p>How do I know the last iteration if I don't know exact number of <code>$d</code>?</p>
  
  <p>I want to do something like:</p>
  
  <pre><code>$d = count( $v2['field_titles'] );
  
  for( $i=0; $i &lt; $d; $i++ ) {
    $current = 3 + $i;
  
    if( this is the last iteration ) {
     echo 'current is ' . $current; 
     // add sth special to the output
    }
    else {
      echo 'current is ' . $current;
    }
  }
  </code></pre>