File_Find::maptree()

File_Find::maptree() – create a view map for a directory

Synopsis

require_once 'File/Find.php';

array &File_Find::maptree ( string $directory )

Description

Map the directory tree given by the directory_path parameter.

Parameter

  • string $directory - contains the directory path that you want to map

Return value

array - a two element array, the first element containing a list of all the directories, the second element containing a list of all the files.

Note

This function can be called statically.

Example

Get the map of a directory

<?php
include "File/Find.php";

$dir "File_Find";
list(
$directories$files) = File_Find::maptree($dir);

echo 
"Directories ";
print_r($directories);

echo 
"Files ";
print_r($files);
?>

The above example will output something similar to:


Directories Array
(
    [0] => File_Find
    [1] => File_Find\dir2
    [2] => File_Find\dir2\2
    [3] => File_Find\dir2\1
    [4] => File_Find\dir2\0
    [5] => File_Find\dir
    [6] => File_Find\dir\txtdir
    [7] => File_Find\dir\dir3
    [8] => File_Find\dir\dir2
)
Files Array
(
    [0] => File_Find\dir2\2\1.txt
    [1] => File_Find\dir2\1\1.txt
    [2] => File_Find\dir2\0\1.txt
    [3] => File_Find\dir\1.txt
    [4] => File_Find\dir\2.txt
    [5] => File_Find\dir\txtdir\5.txt
    [6] => File_Find\dir\dir3\4.bak
    [7] => File_Find\dir\dir3\4.txt
    [8] => File_Find\dir\dir2\3.bak
    [9] => File_Find\dir\dir2\3.txt
)
find matches for a pattern in a directory (Previous) create a recursive view map for a directory (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.