picDirectory = $directory; $this->setPicArray(); } /** * SET PICTURE ARRAY */ public function setPicArray() { $this->picArray = $this->scanDirForFiles(); } /** * @return array $this->picArray */ public function getPicArray() { return $this->picArray; } /** * @return array $tempArray */ private function scanDirForFiles() { $tempArray = []; $dir = $this->picDirectory; if ($handle = opendir($dir)) { $shortDir = strstr($dir, 'Styles'); while (($file = readdir($handle)) !== false) { if (!in_array($file, array(".", "..")) && !is_dir($dir . $file)) { $tempArray[] = $shortDir . $file; } } } return $tempArray; } }