Skip to content

Instantly share code, notes, and snippets.

@mrofi
Created December 24, 2015 02:26
Show Gist options
  • Save mrofi/1b43dc1ebaceaad7d42d to your computer and use it in GitHub Desktop.
Save mrofi/1b43dc1ebaceaad7d42d to your computer and use it in GitHub Desktop.
index.php to list all files in directory. just like apache did but it can be done in php built in server
<?php
$dir = __DIR__; // Directory where files are stored
if ($dir_list = opendir($dir))
{
while($files[] = readdir($dir_list));
sort($files);
closedir($dir_list);
foreach ($files as $file)
{
echo '<p><a href="'.$file.'">'.$file.'</a></p>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment