Skip to content

Instantly share code, notes, and snippets.

@parastuffs
Created February 21, 2016 14:33
Show Gist options
  • Save parastuffs/f406dfdcbde1c139abe8 to your computer and use it in GitHub Desktop.
Save parastuffs/f406dfdcbde1c139abe8 to your computer and use it in GitHub Desktop.
<?php
$dirname = $_SERVER['DOCUMENT_ROOT'].'/';
$dir = opendir($dirname);
while($file = readdir($dir)) {
if($file != '.' && $file != '..' && $file != 'index.php')
{
//echo '<a href="'.$file.'">'.$file.'</a>';
$filelist[] = $file;
}
}
closedir($dir);
$countimg = count($filelist);
$randimg = mt_rand(0, $countimg-1);
echo '<img src="'.$filelist[$randimg].'" alt="Cool story bro" />';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment