Skip to content

Instantly share code, notes, and snippets.

@cmattoon
Last active February 25, 2016 01:48
Show Gist options
  • Save cmattoon/89b298731ebcc5b59403 to your computer and use it in GitHub Desktop.
Save cmattoon/89b298731ebcc5b59403 to your computer and use it in GitHub Desktop.
slides.php
<?php
/**
* Reads a directory and outputs an <img> tag for each *.jpg
* file it finds.
*/
$slides = array_map(function($fname) {
$src = "img/slides/anatomy/" . basename($fname);
return "<img src=\"{$src}\" class=\"slide\">";
}, array_filter(scandir($dir), function($path) {
return (bool)(strpos($path, '.jpg'));
}));
echo implode(PHP_EOL, $slides);
foreach ($slides as $slide) {
echo "<div class=\"slide\">{$slide}</div>" . PHP_EOL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment