Skip to content

Instantly share code, notes, and snippets.

@timbophillips
Created April 17, 2017 17:19
Show Gist options
  • Save timbophillips/2958484ffa57e6f4cdd39acce231caea to your computer and use it in GitHub Desktop.
Save timbophillips/2958484ffa57e6f4cdd39acce231caea to your computer and use it in GitHub Desktop.
simpler php script to return file list as JSON - no option for extension
<?php
/*
call this with GET
returns JSON of files in folder
optional arguments:
folder (defaults to current folder)
*/
if (isset($_GET['folder'])) {
$folder = $_GET['folder'];
}
else {
$folder = './';
}
echo json_encode(array_slice(scandir($folder),2));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment