Here is a single line font based on another answer to a similar question:
Initially, I wanted to use the @Imran solution , but mime_content_type not available, and the server (on which I have zero control) uses older versions of Apache and Php.
So I changed it a bit to work with the file extension, and I give it here.
$imgDir = "images_dir"; // make sure it a directory if (file_exists($imgDir)) { // select the extensions you want to take into account $image_ext = array( 'gif', 'png', 'jpg', 'jpeg' ); foreach (scandir($imgDir) as $entry) { if (! is_dir($entry)) { // no need to weed out '.' and '..' if (in_array( strtolower(pathinfo($entry, PATHINFO_EXTENSION)), $image_ext)) { // do something with the image file. } } } }
The code is verified and works.
Emile bergeron
source share