Wednesday, December 14, 2011

php List Files in Directory

php:
  $dir = opendir(DIR, '[YOUR DIRECTORY PATH HERE]');
  @tmplist = readdir(DIR);
  @list = grep (!/^\./, @tmplist);


tmpl:
<ul>
[$ foreach $file (sort @list) $]
  <li><a href="/drupal-4-7-2/[+ $file +]">[+ $file +]</a></li>
[$ endforeach $]
</ul>

No comments:

Post a Comment