PHP/file/glob: Difference between revisions

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
Created page with "{{fmt/title|PHP filespec wildcard matching & searching|aka "globbing"}} ==About== PHP can do glob-based directory listings and can also check a given filename string against a..."
 
No edit summary
Line 7: Line 7:
* [https://www.php.net/manual/en/function.fnmatch {{fmt/code|fnmatch()}}] reports whether the given filespec string matches the given wildcard string
* [https://www.php.net/manual/en/function.fnmatch {{fmt/code|fnmatch()}}] reports whether the given filespec string matches the given wildcard string
* [https://www.php.net/manual/en/function.glob.php {{fmt/code|glob()}}] accepts a [[filespec]] that includes a [[file mask]], and returns a list of matching [[filespec]]s.
* [https://www.php.net/manual/en/function.glob.php {{fmt/code|glob()}}] accepts a [[filespec]] that includes a [[file mask]], and returns a list of matching [[filespec]]s.
** A file mask in this context can be e.g. {{fmt/code|*.php}} or {{fmt/code|/home/woozle/*.php}} but not {{fmt/code|~/*.php}}.
** The {{fmt/code|*}} and {{fmt/code|?}} wildcards are both recognized.
** The mask may include multiple wildcards, for folders as well as files.
*** '''Example''': {{fmt/code|/b*/b*}} will return all files beginning with b inside root-level folders beginning with b.

Revision as of 14:10, 24 August 2022

Template:Fmt/title

About

PHP can do glob-based directory listings and can also check a given filename string against a given glob string.

See also: globbing

Functions