Jump to content

Custom list from directory


smordue

Recommended Posts

I am trying to create a customized <ul> from a list of files in a directory. I need the final result to be:

 

<li><img src="img/Fall in Germany.jpg" title="Fall in Germany" alt="Fall in Germany"/></li>

 

Here is where I am so far:

 

<?php
if ($handle = opendir('img')) {
   while (false !== ($file = readdir($handle)))
      {
          if ($file != "." && $file != "..")
  {
          	$thelist .= '<li><img src="img/'.$file.'" title="'.$file.'" alt="'.$file.'"/></li>';
          }
       }
  closedir($handle);
  }
?>
<ul class="gallery">
<?=$thelist?>
</ul>

 

What I need to be able to do is strip off the file extension for the title and alt tags only.

 

Link to comment
https://forums.phpfreaks.com/topic/185902-custom-list-from-directory/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.