Skip to content

Instantly share code, notes, and snippets.

@timbophillips
Created April 18, 2017 02:42
Show Gist options
  • Save timbophillips/d3e04a003bc5c4469822d3fd6c8a976b to your computer and use it in GitHub Desktop.
Save timbophillips/d3e04a003bc5c4469822d3fd6c8a976b to your computer and use it in GitHub Desktop.
this script when called will output the list of files in its folder, minus itself, as JSON
<?php
/* this script when called will output the list of files in its folder, minus itself, as JSON */
$files = scandir('./');
$justFilesNoFolders = array_filter($files, function($item) {
return !is_dir($item);
}
);
$withoutThisScript = array_filter($justFilesNoFolders, function($item) {
return $item != basename(__FILE__);
}
);
$justValues = array_values($withoutThisScript);
$asJSONString = json_encode($justValues);
echo $asJSONString;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment