Source Code for /public/03-lists-and-loops/loop-through-files.php

<?php
// Get a list of all the .jpg files in the img/fruit directory:
$files = glob('../img/fruit/*.jpg');

// Loop through each file and display it as an image:
foreach( $files as $file ) {
  ?>

  <img src="<?php echo $file; ?>"
     width="200"
    height="200"
     style="border: 1px solid black;">

  <?php
}