Skip to content

Instantly share code, notes, and snippets.

@k0nsl
Created August 5, 2014 19:25
Show Gist options
  • Save k0nsl/b9075ed60db0241410c5 to your computer and use it in GitHub Desktop.
Save k0nsl/b9075ed60db0241410c5 to your computer and use it in GitHub Desktop.
List files using glob()
<!-- modPDF.php <k0nsl> -->
<div class="maintitle">Recently Added eBooks:</div>
<p><br><center><a href="/?new"><img src="/graphs/My-Ebooks-icon.png" border="0" title="" alt="" /></a></center></p>
<br>
<?php
$show = 10;
$dir = '/home/neophyte/public_html/WNLibrary/Portabel Documents/'; // Leave as blank for current
if($dir) chdir($dir);
$files = glob( '*.{pdf}', GLOB_BRACE );
usort( $files, create_function('$b, $a', 'return filemtime( $a ) - filemtime( $b );') );
for ( $i = 0; $i < $show; ++$i )
echo '&#171; <a href="/Portabel Documents/', $file = $files[$i], '">', $file, '</a><br />', "\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment