I have an array of images being displayed from a specific directory using the following code:
<?php
$dir = "img";
$files = scandir($dir);
echo '<pre>', htmlspecialchars(print_r($files, true)), "</pre>\n";
?>
The output of this code is as follows:
Array
(
[0] => .
[1] => ..
[2] => image_1.png
[3] => image_2.png
[4] => image_3.png
)
What I would like to do is display the array of images as shown below thus removing [x] =>
for each image and also removing Array ( )
.
image_1.png
image_2.png
image_3.png
Im not sure how to go about this. I have never really worked with arrays before therefore the only methods I can think of are preg_replace()
or str_replace()
, but honestly not sure where I would start.
Any help would be kindly appreciated.