Skip to content

Instantly share code, notes, and snippets.

@dewski
Created February 21, 2010 06:59
Show Gist options
  • Select an option

  • Save dewski/310176 to your computer and use it in GitHub Desktop.

Select an option

Save dewski/310176 to your computer and use it in GitHub Desktop.
<?php
function returnimages($dirname="images") {
$pattern="\.(jpg|jpeg|png|gif|bmp)$";
$files = array();
if ($handle = opendir($dirname)) {
while (false !== ($file = readdir($handle))) {
$files[] = $file;
}
closedir($handle);
}
return $files;
}
foreach(returnimages() as $image) {
echo "<img src='images/$image' alt='' />";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment