Skip to content

Instantly share code, notes, and snippets.

@guibranco
Created July 10, 2018 00:01
Show Gist options
  • Save guibranco/2ada0af85e3140206f0a1a87e0fb30c1 to your computer and use it in GitHub Desktop.
Save guibranco/2ada0af85e3140206f0a1a87e0fb30c1 to your computer and use it in GitHub Desktop.
Script para listar arquivos em um diretório e retornar os dados no formato JSON - Facebook - PHP Brasil - https://www.facebook.com/groups/142151625841770/permalink/1850978598292389/
<?php
$dir = "./images/";
if (!($handle = opendir($dir)))
die("Unable to open the directory $dir");
$registros = array();
while (false !== ($file = readdir($handle))) {
if ($file === "." or $file === "..")
continue;
array_push($registros, array("IMAGE" => $file));
}
closedir($handle);
echo json_encode($registros);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment