Skip to content

Instantly share code, notes, and snippets.

View benedict-w's full-sized avatar

Benedict benedict-w

View GitHub Profile
@benedict-w
benedict-w / read_files_from_dir.php
Last active February 24, 2020 04:31
PHP script to read files from a DIR parsing through a filename regex to match extensions
<?php
$files = array();
$folder = '../images';
$extensions = 'png';
if (is_dir($folder)){
$dir = opendir($folder);
while ($file = readdir($dir)) {
if (preg_match("/^[^\.].+\.{$extensions}$/i", $file)) {