How add a self growth number in foreach?

<?php foreach($page->images()->sortBy('sort', 'asc') as $image): ?>
	<li><a href=""><img src="<?= $image->url() ?>" alt=""></a></li>
<?php endforeach ?>

now I want print like this:

	<li uk-slideshow-item="0"><a href=""><img src="" alt=""></a></li>
	<li uk-slideshow-item="1"><a href=""><img src="" alt=""></a></li>
	<li uk-slideshow-item="2"><a href=""><img src="" alt=""></a></li>
...

Similar to a question I asked months ago. The answer lies in this thread.

Something like this should do it:

<?php 
$images = $page->images()->sortBy('sort', 'asc')
foreach($images as $image): 
  $index = $images->indexOf($images); // add offset if required
?>
  <li><a href="#" uk-slideshow-item="<?= $index ?>"><img src="<?= $image->url() ?>" alt=""></a></li>
<?php endforeach ?>

Good job, Thanks!
but a little issue, Now I fixed!

<?php 
$images = $page->images()->sortBy('sort', 'asc');
foreach($images as $image): 
  $index = $images->indexOf($image); // add offset if required
?>
  <li><a href="#" uk-slideshow-item="<?= $index ?>"><img src="<?= $image->url() ?>" alt=""></a></li>
<?php endforeach ?>