Php image array

I’m trying to display all the images inside a certain directory. Here’s what I have so far…

 <?php

$dir1 = "001/"; $images1 = scandir($dir1);

$i1 = sizeof($images1);

foreach ($images1 as $value)

{ echo "<img src='001/" . $images1[$i1]; . "' alt='' />" }

?> 

You were close. However, the foreach statement wasn’t used correctly, the use of sizeof doesn’t make any sense, and your echo statement was invalid HTML.

$dir1 = "001/"; 

$images1 = scandir($dir1);

//if there are items in the directory
if(!empty($images1)){

    //for each item found in the directory
    foreach ($images1 as $item){ 

        //if the item found is not a directory, is not a symbol for another directory (".." or ".")
        if(!is_dir($dir1.$item) && $item != ".." && $item != "."){
            
            //print the image HTML tag
            echo '<img src="' . $dir1 . $item . '" alt="">'; 

        }

    }

}

It’s working now, thank you so much!