Different glob() results from local to server (Windows vs Linux)
I'd like to select only files that starts with a number or a letter:
$files = glob($xsl_dir_path . "/[^a-zA-Z0-9]*.xsl");
$files = array_map('basename', $files);
There are 3 files: a.xsl, b.xsl, _functions.xsl. I don't want to select _functions.xsl file.
- Result: local (Windows): a.xsl, b.xsl
- Result: server (Lin开发者_StackOverflowux): _function.xsl
*Edited (again) *
My bad, glob probably doesn't have regex as pattern match.
This won't work then: (?<![^/])[a-zA-Z0-9][^/]*\.xsl$
(just matches the filename.xsl preceeded with either a /
or begining of string. )
However, for more control, use a glob '*.*' or something broad, then filter the list that glob produces with a regex like above. Its an extra step but will probably get uniform results across OS's
You are negating the class match, try:
$files = glob($xsl_dir_path . "/[a-zA-Z0-9]*.xsl");
$files = array_map('basename', $files);
精彩评论