Hey all, new to the forums and semi-new to php. I am in a php class that goes through the coding aspect (leaving out safety etc unfortunately). Anyways I have an assignment with 1 particular thing giving me trouble:
Basically I have to make a page that shows the contents of a directory BUT if there are no text files in the folder I am supposed to kill the script. Mind you I am not on Php 5 yet due to instability.
Code I tried (for that specific part of the script) was:
$directory = dir("./courses/");
if(!(isset($directory[2]))){
die("No files in directory");
}
To my knowledge $directory[0] would be taken up by "." and [1] would have ".." so I thought if [2] isn't set then there isnt an actual file in the directory. I am sure there must be a better way of doing this however as [2] could easily be taken up by a folder or image and still come out true that there is a txt file...
Look forward to some help on this, Thanks.