I a trying to write a php script that displays file names in a dir that relate to a certain category... kind of like this:
images/dog_1.jpg
images/dog_2.jpg
images/dog_3.jpg
There will be other categories in the dir.
So far all I have been able to is display all the files in a dir.
$directory = 'images/';
$directory = 'images/';
$directoryFiles = array();
$category = 'dog';
if ($handle = opendir($directory)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$directoryFiles[] = $file;
}
}
closedir($handle);
}
for($i=0; $i<count($directoryFiles); $i++) {
echo $directory.$directoryFiles[$i]; print "\n";
}