I need a very specific function in PHP. Basically, I have two strings as arguments, one of which is a pattern that contains wildcards of variable length (*), and one of which is a string that matches that pattern. I need to get an array of the strings from the latter string that fill in the wildcards in the pattern.
For example:
What's the cleanest way to do this? Bear in mind that these are not always strings of english words as in the example, they could be any random characters.
You could just replace the wildcards with a regex equivalent, and run it through preg_match.
Because it really does sound like homework, I won't give any specific code either, but I'd make good use of preg_replace (to replace the wildcards with regex equivalents) and preg_match (to build the array of matching substrings).