Created
May 12, 2014 10:24
-
-
Save tjarksaul/0b6bc678aa4d38dd9e8e to your computer and use it in GitHub Desktop.
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 | |
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