Skip to content

Instantly share code, notes, and snippets.

@atillay
Last active May 27, 2018 19:39
Show Gist options
  • Save atillay/5c3757384a73f50fe9f2b229f41eb34d to your computer and use it in GitHub Desktop.
Save atillay/5c3757384a73f50fe9f2b229f41eb34d to your computer and use it in GitHub Desktop.
yolo
<?php
define('PATTERN', '*.{jpg,jpeg,gif,png}');
function getFilesIn(string $path): array
{
$files = glob($path . '/' . PATTERN, GLOB_BRACE);
foreach (glob($path . '/*', GLOB_ONLYDIR|GLOB_NOSORT) as $subDir) {
$files = array_merge($files, getFilesIn($subDir));
}
return $files;
}
$images = getFilesIn(__DIR__);
var_dump($images);
die;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment