Url Path And Wildards in PHP

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. :blush:

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! :slight_smile:

The function fnmatch might also be useful in this particular case.

There are two ways to approach this –

  1. As a substring-matching problem. Check if $variable is the beginning of whatever string you’re comparing it to with substr() and ==.

  2. 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.