-
-
Save raihan-uddin/4cfe35d5c675354a0edfa87cbc52bdef to your computer and use it in GitHub Desktop.
PHP script to read files from a DIR parsing through a filename regex to match extensions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$files = array(); | |
$folder = '../images'; | |
$extensions = 'png'; | |
if (is_dir($folder)){ | |
$dir = opendir($folder); | |
while ($file = readdir($dir)) { | |
if (preg_match("/^[^\.].+\.{$extensions}$/i", $file)) { | |
$files[] = $file; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment