Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Image aggregator (See related posts)

This PHP snippet outputs the contents of a table (beginning & ending tags not included) containing all the images from the current directory.
<?PHP
 $columns = 3;
 $im = glob("*.{gif,jpg,png}", GLOB_BRACE);
 $rows = ceil(count($im) / $columns);
 for ($i = 0; $i < $rows; $i++) {
  echo "\n<TR>";
  for ($j = $columns*$i; isset($im[$j]) && $j - $columns*$i < $columns; $j++) {
   echo "<TD>$im[$j]<BR><IMG SRC='$im[$j]'></TD>";
  }
  echo "</TR>";
 }
?>

You need to create an account or log in to post comments to this site.


Click here to browse all 4852 code snippets

Related Posts