> I am showing a directory of files and I don't what all the files to
> show on the screen. I was able to get the . and the .. not to show
> with what I have below but there are some other files in there that look
> like this mylist.confg. I don't want them to show in the directory
> list. I tried && $files != "*.config" but this did not work .
> Anybody have an suggestions on how to do this . I have look through
> the manual and the mailing list but can't figure out how to make the
> pattern to keep this from showing
>
> if ($handle = opendir('/path/to/list/directory')) {
> while (false !== ($files = readdir($handle))) {
> if ($files != "." && $files != "..") {
> echo $files;
> }
!= doesn't understand the glob (*) character, so the easiest way to make
your example work is to use a regular expression match. Something like:
if ($files != "." && $files != ".." && !preg_match("/\.config$/", $files)) {
should do the trick. However, if you anticipate adding any more filters
on the listing (.cfg, .txt, .conf, etc...) you might want to come up
with a more general way to add filters besides simply tacking on stuff
with &&. One thought might be to keep an array of patterns, and do a
match on the whole array. When a new file needs to be filtered, simply
add an entry to the array, keeping your code more-or-less clean.
It's up to you, though.
--
[ joel boonstra | [EMAIL PROTECTED] ]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php