I’m trying to figure out how to use wildcard with url in PHP. I would like to have something like $variable =“http://www.mydomain.com/subdirectory1/*” So the variable would match any file and directory (path) in my subdirectory1. I think it has something to do with following characters . () * but I failed to construct the right form. Any ideas? I’m PHP noob.
Thank you for the suggestions guys! I’ve already found other way to resolve my problem but I will check out your suggestions too as I need to learn!
The function fnmatch might also be useful in this particular case.
There are two ways to approach this –
As a substring-matching problem. Check if $variable is the beginning of whatever string you’re comparing it to with substr() and ==.
With regular expressions. That’s that language where the “. () *” symbols have meaning. Google “regular expression” for tutorials, but there’s a steep learning curve before it clicks for most people.