How can PHP be used to access and display images from a local directory on a server?
To access and display images from a local directory on a server using PHP, you can use the `scandir()` function to get a list of files in the directory, filter out only the image files, and then loop through them to display each image using the `<img>` tag.
<?php
$directory = 'path/to/images/';
$files = scandir($directory);
foreach($files as $file){
if(in_array(pathinfo($file, PATHINFO_EXTENSION), array('jpg', 'jpeg', 'png', 'gif'))){
echo '<img src="' . $directory . $file . '" alt="' . $file . '">';
}
}
?>