Given a directory of animal pictures (images.zip), write a PHP webpage animals.php which displays these pictures.
If no query parameter is set, then the page should simply display all of the images in the
images
directory. The user can set an animal
query parameter to
choose whether to display only puppy pictures or only kitty pictures. For example, if the
user entered the following URL:
animals.php?animal=puppy
Then the page should only display puppy pictures. You may assume that the animal query
parameter is either kitty
or puppy
.
<div> <?php $animal = ""; if (isset($_GET["animal"])) { $animal = $_GET["animal"]; } $files = glob("images/{$animal}*.jpeg"); foreach ($files as $image) { ?> <img src="<?= $image ?>" alt="animal picture" /> <?php } ?> </div>