Support Joomla!

references:joomla.framework:filesystem:jfolder-files

files

API Package Subpackage Class Method Reference Last reviewed Doc status
API Home Package Joomla.Framework Subpackage FileSystem Class JFolder Method files Reference files() Never Work in Progress

Utility function to read the files in a folder. This function uses FTP if enabled, otherwise, it will use the built in PHP functions. An array containing the files in the folder is returned.

Syntax

array files ( $path, $filter, $recurse, $fullpath, $exclude )

$path string is a string containing the path of the folder to read.
$filter string is a string containing a filter for file names. The filter is applied as a regular expression, so this syntax should be followed. This parameter is optional and if omitted defaults to an empty string.
$recurse boolean is a flag which specifies whether or not sub-folders should be recursively searched. This parameter is optional and if omitted defaults to false.
$fullpath boolean is a flag which specifies whether or not the full path to the file should be returned. This parameter is optional and if omitted defaults to false.
$exclude array is an array of strings containing filenames that should be excluded from the result. This parameter is optional and if omitted defaults to an array containing the entries ‘.svn’ and ‘CVS‘, which will result in SVN and CVS files being filtered out.

Examples

Example 1

Basic example:

Example 1

jimport( 'joomla.filesystem.folder' );
$files = JFolder::files( 'templates' );
print_r( $files );

might produce:

Result

Array ( [0] => index.html )

Example 2

Display only PHP files in all sub folders, showing full paths:

Example 2

jimport( 'joomla.filesystem.folder' );
$files = JFolder::files( 'templates', 'php$', true, true );
print_r( $files );

might produce:

Result

Array
(
    [1] => templates\_system\error.php
    [2] => templates\_system\offline.php
    [0] => templates\rhuk_milkyway\index.php
)

Discussion

Full name:
E-Mail:
 
references/joomla.framework/filesystem/jfolder-files.txt (716 views) · Last modified: 2007/08/15 15:06