$files->find() method

Find all files in the given $path recursively, and return a flat array of all found filenames

Available since version 3.0.96.

Usage

// basic usage
$array = $files->find(string $path);

// usage with all arguments
$array = $files->find(string $path, array $options = []);

Arguments

NameType(s)Description
pathstring

Path to start from (required).

options (optional)array

Options to affect what is returned (optional):

  • recursive (int|bool): How many levels of subdirectories this method should descend into beyond the 1 given. Specify 1 to remain at the one directory level given, or 2+ to descend into subdirectories. (default=10) In 3.0.180+ you may also specify true for no limit, or false to disable descending into any subdirectories.
  • extensions (array|string): Only include files having these extensions, or omit to include all (default=[]). In 3.0.180+ the extensions argument may also be a string (space or comma separated).
  • excludeDirNames (array): Do not descend into directories having these names (default=[]).
  • excludeHidden (bool): Exclude hidden files? (default=false).
  • allowDirs (bool): Allow directories in returned files (except for '.' and '..')? Note that returned directories have a trailing slash. (default=false) 3.0.180+
  • returnRelative (bool): Make returned array have filenames relative to given start $path? (default=false)

Return value

array

Flat array of filenames


$files methods and properties

API reference based on ProcessWire core version 3.0.200

Twitter updates

  • Weekly update: Smooth rollout for ProcessWire 3.0.200 main/master, plus getting started on a new WP-to-PW site conversion and why they can be so rewarding— More
    20 May 2022
  • New main/master version of ProcessWire that has more than 220 commits, resolves more than 80 issues, adds numerous new features, performance improvements and optimizations, and consumes HALF the disk space of our previous release— More
    13 May 2022
  • Summary of weekly core updates for 22 April 2022 More
    22 April 2022

Latest news

  • ProcessWire Weekly #419
    In issue 419 of ProcessWire Weekly we'll check out this week's core updates, introduce a brand new recipe of the week, and more. Read on!
    Weekly.pw / 21 May 2022
  • ProcessWire 3.0.200 new master/main version
    This new main/master version has more than 220 commits, resolves more than 80 issues, adds numerous new features, performance improvements and optimizations, and consumes HALF the disk space of our previous release. This post covers all the details.
    Blog / 13 May 2022
  • Subscribe to weekly ProcessWire news

“Yesterday I sent the client a short documentation for their ProcessWire-powered website. Today all features already used with no questions. #cmsdoneright—Marc Hinse, Web designer/developer