'How to get the parts a wildcard matched against from fnmatch?
fnmatch returns true if a filename is like a pattern, but I would like to know which parts of the pattern matched against the parts of the filename
ie:
pattern: pages/*
filename: pages/test
result:
[
0 => ["patten" => "pages/", "filename" => "pages/"],
1 => ["patten" => "*", "filename" => "test"],
];
I'd like it to support every wildcard fnmatch supports, since that's the main part of this
I'd try parsing the string myself but I don't know what methods fnmatch uses, and I'd need it to be consistent. I only use the FNM_CASEFOLD option so it wouldn't need to support all the options. I was just hoping PHP had something built in to give me the data.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
