Skip to content

Instantly share code, notes, and snippets.

@justinhough
Created October 11, 2015 06:21
Show Gist options
  • Select an option

  • Save justinhough/725f70540f151763cb8f to your computer and use it in GitHub Desktop.

Select an option

Save justinhough/725f70540f151763cb8f to your computer and use it in GitHub Desktop.
PHP Directory Listing
<?php
foreach (glob("*.txt") as $filename) {
echo "$filename size " . filesize($filename) . "\n";
}
preg_grep('#\.zip$#', glob('/dir/somewhere/*'), PREG_GREP_INVERT)
// http://cowburn.info/2010/04/30/glob-patterns/
if (fnmatch("*gr[ae]y", $color)) {
echo "some form of gray ...";
}
//Easy way to get rid of the dots that scandir() picks up in Linux environments:
$directory = '/path/to/my/directory';
$scanned_directory = array_diff(scandir($directory), array('..', '.'));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment