Skip to content

Instantly share code, notes, and snippets.

@tjarksaul
Created May 12, 2014 10:24
Show Gist options
  • Save tjarksaul/0b6bc678aa4d38dd9e8e to your computer and use it in GitHub Desktop.
Save tjarksaul/0b6bc678aa4d38dd9e8e to your computer and use it in GitHub Desktop.
<?php
header('Content-type: application/json');
print (new JSONCreator)->getJSON();
class JSONCreator
{
private $files;
public function __construct()
{
$this->files = [];
}
public function getJSON()
{
$this->getPDF();
return json_encode($this->files);
}
private function getPDF()
{
$iterator = new DirectoryIterator(dirname(__FILE__));
foreach ($iterator as $fileInfo)
{
if ($fileInfo->isDot()) continue;
if (substr($fileInfo->getFilename(), -4) == '.pdf')
$this->files[] = [
'name' => $fileInfo->getFilename(),
'mtime' => $fileInfo->getMTime()
];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment