Skip to content

Instantly share code, notes, and snippets.

@joshjensen
Created May 7, 2012 17:26
Show Gist options
  • Save joshjensen/2629102 to your computer and use it in GitHub Desktop.
Save joshjensen/2629102 to your computer and use it in GitHub Desktop.
Pull Images and Return JSON Array
<?php
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json;');
$file_array = array();
if ($handle = opendir('.')) {
while (false !== ($entry = readdir($handle))) {
$ext = pathinfo($entry, PATHINFO_EXTENSION);
if ($entry != "." && $entry != ".." && $entry != ".DS_Store" && $entry != 'index.php' && $ext == 'jpg' || $ext == 'png') {
array_push($file_array, 'http://imattic.com/paper/'.$entry);
}
}
closedir($handle);
}
echo json_encode($file_array);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment