Skip to content

Show all images in a folder with PHP

by Mats Djärf on April 9th, 2010

This PHP-script will show all images located in a folder. I have add some TABLE-stuff if you want to print to paper.

<?php
//Your folder
$files = glob("icons/*.*");

$colCnt=0;
echo '<table border="0" style="width:590px;">';

for ($i=1; $i<count($files); $i++)
  {
  $colCnt++;
  if ($colCnt==1)
  echo '<tr>';
  echo '<td width="25%" style="font-size:8.5px; font-family:arial">';

  $num = $files[$i];
  echo '<img src="'.$num.'" align="absmiddle" /> ';
  print substr(substr($num,6,100),0,-4);

  echo '</td>';

  if ($colCnt==4)
    {
    echo '</tr>';
    $colCnt=0;
    }
  }

echo '</table>';
?>

Share and enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • StumbleUpon
  • Technorati
  • Ping.fm
  • Twitter

From → Code, Software

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS

*