[SOLVED] Multiple Patterns in glob() ?
Posted: Thu Jun 17, 2004 11:14 pm
Hey all, first post. 
Any way to specify multiple patterns in a glob() function?
I've searched high and low all over google, phuse, php.net, this forum, and others, and the closest I've found is another person asking the same question in:
viewtopic.php?t=11420
but his question seems to have been lost/overlooked in the rest of the topic.
I understand the concept of making multiple globs, but surely there's a way to specify multiple patterns in one glob?
For example, say this is my original code:
Now, anyone can see that all this does is print some html to display all image files matching *.jpg, some page breaks, the filename below the image.
What I'd like to be able to do is add *.gif (or anything else) to that same glob as well. I can set up seperate globs for this, but I'd rather not, as the first function to run will display, then the 2nd, and so on, ignoring the natural alphabetical order of the file listing, save where it relates to the given pattern in the given glob.
It would be nice to be able to specify multiple patterns for this reason. I have tried several other language standards for multiple patterns that I have found, but none seem to work (LOL yes I know some of them were silly to try...but hey what could it have hurt/I'm a n00b):
("*.jpg" "*.gif")
("*.jpg *.gif")
({jpg gif})
Is there a format for PHP that I just haven't found in my searches? Or is this just not supported?
Thanks a million.
Any way to specify multiple patterns in a glob() function?
I've searched high and low all over google, phuse, php.net, this forum, and others, and the closest I've found is another person asking the same question in:
viewtopic.php?t=11420
but his question seems to have been lost/overlooked in the rest of the topic.
I understand the concept of making multiple globs, but surely there's a way to specify multiple patterns in one glob?
For example, say this is my original code:
Code: Select all
<?php
foreach (glob("*.jpg") as $filename) {
print ("<img src="$filename">\n");
print ("<br>\n");
print ("$filename\n");
print ("<br>\n");
print ("<br>\n");
print ("<br>\n");
}
?>What I'd like to be able to do is add *.gif (or anything else) to that same glob as well. I can set up seperate globs for this, but I'd rather not, as the first function to run will display, then the 2nd, and so on, ignoring the natural alphabetical order of the file listing, save where it relates to the given pattern in the given glob.
It would be nice to be able to specify multiple patterns for this reason. I have tried several other language standards for multiple patterns that I have found, but none seem to work (LOL yes I know some of them were silly to try...but hey what could it have hurt/I'm a n00b):
("*.jpg" "*.gif")
("*.jpg *.gif")
({jpg gif})
Is there a format for PHP that I just haven't found in my searches? Or is this just not supported?
Thanks a million.