To match what you want you could use
/.*.html$/ in preg_match or something like that in ereg. I tend to use preg just because I like to have all the power of perl regexs.
Anyway, the regex I wrote says:
Match zero or more characters followed by .html and where the .html must be at the end of the string. ($ is an anchor)
You should carefully read the pattern matching help online at php.net. then read it again...
BTW you don't need to write: while (($file = readdir($dirPath)) != false)
because:
while (($file = readdir($dirPath))) is the same thing. You should be more lazy.
Mark S. Fleming wrote:
Good Evening,
I have the following snippet of code :
<?php
$dirPath = opendir(´images/march´);
while (($file = readdir($dirPath)) != false) {
if ($file != "." && $file != "..") {
echo "The Filename is $file ";
}
}
?>
I would like to extend it so that if the file matches *.html, it will ignore those files, and only report the others (which happen to be .jpg files). I'm not sure how I can make that test...I looked up chop and trim, but those didn't help. Can somebody point me in the right direction?
Thanks!