PHP Loop start at 0 instead of 1 -


trying increasing number each image has start @ 0, outputting 1 , don't know why!

any appreciated, in advance!

  <div id="carousel">      <ul class="thumbs">     <?php $counts = 0 ; ?>          <?php  foreach( $images $image ): $counts++; ?>             <li>                 <a data-slide-index="<?php echo $counts ;?>" href=""> <img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" /></a>             </li>  <?php endforeach; ?>      </ul>   </div>  <?php endif; ?> 

because increamenting $counts before echo

so :

<?php $counts = -1 ; ?> 

or this:

foreach( $images $image ) {     echo '<li>         <a data-slide-index="' . $counts . '" href="">         <img src="' . $image['sizes']['thumbnail'] . '" alt="' . $image['alt'] . '" /></a>     </li>';     $counts++; } 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -