2
I have a project and there are several folders containing image files belonging to gallery: I need to optimize this by getting all the images from a given directory and generating them in HTML.
Basically the project receives the directory in a parameter of the URL, being thus below: localhost/?g=diretorio1%2Fgaleria1%2F
.
In this case all files in the directory 'directory1/galeria1/' will be filtered to accept only image files and soon after the HTML code will be generated <a href=""><img src="diretorio1/galeria1/x" /></a>
. Where x = name and extension of each image file.
I don’t have much notion of PHP, preferably orient me with articles or detail the answer so I can understand.
It worked perfectly! Thank you :-)
– Corvo
I could understand most of it, in this case how can I add the png extension (*. png) ? It would be glob($directory . " *. jpg", $directory . " *. png") ?
– Corvo
I found it. It’s glob($directory . " *. {jpg,png,gif}", GLOB_BRACE);
– Corvo
The correct thing would be to only list images that are in the directory.
– Sr. Bigode