Skip to content

Instantly share code, notes, and snippets.

@darkcolonist
Created November 7, 2016 02:36
Show Gist options
  • Save darkcolonist/e7604f74302df19ba7944ef3e0f519de to your computer and use it in GitHub Desktop.
Save darkcolonist/e7604f74302df19ba7944ef3e0f519de to your computer and use it in GitHub Desktop.
display all images inside a folder in a tabular format (php)
<?php
/**
* original source: http://stackoverflow.com/a/11903460/27698
*/
// $dirname = "media/images/iconized/";
$dirname = "./";
$images = glob("*.{jpg,png,gif}", GLOB_BRACE);
echo "<table>";
echo "<tr><th>source</th><th>image preview</th></tr>";
foreach($images as $image) {
echo '<tr>';
echo '<td>'.$image.'</td>';
echo '<td><img src="'.$image.'" /></td>';
echo '</tr>';
}
echo "</table>";
@darkcolonist
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment