hi i have a template page which displays different things depending on the variable 'step_number'.
some of the steps have images some dont so i want to check if the image is in the sub folder before i decide weather to dispaly it or not.
subfolders like this
step3/image/
Is there any way you can use comand lines like 'ls' to look in a folder
cheers hope yous can help?you could use:
$dh = opendir("./step3/");
while(false !== ($filename = readdir($dh)))
$contents[] = $filename;
close_dir($dh);
which generates a list of all contents for the given directory.
then you just have to search the contents array to see if you got a match.oops - sorry, I cribbed that code off a prototype script I had written.
fixed it proper now.why wouldn't using file_exists() work?
<!-- m --><a class="postlink" href="http://ca2.php.net/file-existsyeah">http://ca2.php.net/file-existsyeah</a><!-- m --> - i forgot about file_exists() - my code above is from a script I made to display pictures in a folder as a photo-album - so I needed to make lists.
some of the steps have images some dont so i want to check if the image is in the sub folder before i decide weather to dispaly it or not.
subfolders like this
step3/image/
Is there any way you can use comand lines like 'ls' to look in a folder
cheers hope yous can help?you could use:
$dh = opendir("./step3/");
while(false !== ($filename = readdir($dh)))
$contents[] = $filename;
close_dir($dh);
which generates a list of all contents for the given directory.
then you just have to search the contents array to see if you got a match.oops - sorry, I cribbed that code off a prototype script I had written.
fixed it proper now.why wouldn't using file_exists() work?
<!-- m --><a class="postlink" href="http://ca2.php.net/file-existsyeah">http://ca2.php.net/file-existsyeah</a><!-- m --> - i forgot about file_exists() - my code above is from a script I made to display pictures in a folder as a photo-album - so I needed to make lists.