Created
April 18, 2017 02:42
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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