Skip to content

Instantly share code, notes, and snippets.

@benmills
Created December 9, 2009 01:28
Show Gist options
  • Save benmills/252175 to your computer and use it in GitHub Desktop.
Save benmills/252175 to your computer and use it in GitHub Desktop.
<?php $dir = ".";
function contents($dir, $path = null) {
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
$odd = false;
while (($file = readdir($dh)) !== false) {
if ($file != "." && $file != ".." && $file != "index.php") {
// Do something with this file
}
}
closedir($dh);
}
}
}
// Open a known directory, and proceed to read its contents
contents($dir); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment