Skip to content

Instantly share code, notes, and snippets.

@rileypaulsen
Created August 12, 2013 04:45
Show Gist options
  • Save rileypaulsen/6208296 to your computer and use it in GitHub Desktop.
Save rileypaulsen/6208296 to your computer and use it in GitHub Desktop.
list the files in a directory in JSON
<?php
$files = array();
if ($handle = opendir('.')):
while (false !== ($entry = readdir($handle))):
if ( !empty($entry) && $entry != "." && $entry != ".." && $entry != "" && $entry != 'index.php'):
$files[] = $entry;
endif;
endwhile;
closedir($handle);
endif;
die(json_encode($files));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment