Exclude php files from scandir

  php

I got a script that displays all my images from folder, but rn it’s displaying a php file aswell how can i exclude it?

    $images_dir = "/Images/";
    $images = scandir($images_dir);
    arsort($images);
    $ignore = array(".", "..", ".php");
    foreach($images as $curimg){
        if(!in_array($curimg, $ignore)) {
            echo "<a href="$images_dir$curimg"><img src="". $images_dir . '/' . $curimg ."" data-src="". $images_dir . '/' . $curimg .""></a>n";
        }
    }

As you can see i tried adding ".php" but it still includes it. So idk what to do.

Source: Ask PHP

LEAVE A COMMENT