Search code examples
phpglob

What kind of special characters can glob pattern handle?


So far I have only worked with *, but, are there something like lookaheads, groups?

I would like to get all *.php except controller.php.

What I have to alter in this glob(dirname(__FILE__) . DIRECTORY_SEPARATOR . '*.php') call, to exclude controller.php?

Or should I avoid glob and work with something else instead?


Solution

  • php glob() uses the rules used by the libc glob() function, which is similar to the rules used by common shells. So the patterns that you are allowed to use are rather limited.

    glob() returns an array of all the paths that match the given pattern. Filtering controller.php out the result array is one solution.