Counter inside a foreach loop
-
I know I’m doing something wrong here but I can figure out how to order this loop. I’m trying to track a slideshow and I’m using counter to output what slide got clicked. Can anyone point me in the right direction?
<ul class="slides"> <?php $counter = 0; <?php foreach( $images as $image ): ?> $i++; <a href="#">', '<?php echo '$counter'; ?>');"> <li> <img src="<?php echo $image['sizes']['small-thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" /> </li> </a> $counter++; <?php endforeach; ?> ?>
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Counter inside a foreach loop’ is closed to new replies.