When you have the large collection of images files on a directory and you wants to convert it into the photo gallery.
Add image file manually to your page one by one which you want to show. The problem with this solution is it is time-consuming and you have to check all image links if any update in future.
Store image names in the Database table and use it to get images.
Read all files from target directory and generate photo gallery.
The second and third solution are better but in this post, I will show you how to implement the third solution with PHP.