I have been trying to figure out a way to list all files contained within a directory. I'm not quite good enough with php to solve it on my own so hopefully someone here can help me out.
I need a simple php script that will load all filenames contained within my images directory into an array. Any help would be greatly appreciated, thanks!
Try glob
Something like:
foreach(glob('./images/*.*') as $filename){ echo $filename; }
scandir()
- List files and directories inside the specified path
$images = scandir("images", 1); print_r($images);
Produces:
Array ( [0] => apples.jpg [1] => oranges.png [2] => grapes.gif [3] => .. [4] => . )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With