getPathPhpFiles (function)

Last updated: Mon, Apr 17, 2023 10:10 am
Return to Knowledgebase

Purpose

Retrieve a list of all .php files in folder

Location

users/helpers/permissions.php

Parameters

# Parameter Data Type Required Description
1 $absRoot string Yes The absolute path of the website's root directory
2 $urlRoot string Yes The website's URL root.
3 $fullPath string Yes The full path of the directory to search for PHP files.

Returns

Data Type Description of Returned Data
array Returns an array of file paths relative to the website's URL root if PHP files are found in the directory specified by $fullPath, or null if no PHP files are found.

Example

getPathPhpFiles($abs_us_root,$us_url_root,'usersc/plugins/');

Further Documentation:

The function searches for PHP files in the specified directory and returns an array of file paths relative to the website's URL root.

The function returns an array of file paths relative to the website's URL root if PHP files are found in the directory specified by $fullPath, or null if no PHP files are found.

Example usage:

Suppose the website's root directory is /var/www/example.com, the URL root is http://example.com, and we want to get an array of PHP files in the directory includes/myphpfiles. We can call the function like this:


$absRoot = '/var/www/example.com';
$urlRoot = 'http://example.com';
$fullPath = 'includes/myphpfiles/';

$phpFiles = getPathPhpFiles($absRoot, $urlRoot, $fullPath);


If there are two PHP files in the includes/myphpfiles directory, say file1.php and file2.php, then $phpFiles will be an array with the following values:
 
Array(
[includes/myphpfiles/file1.php] => includes/myphpfiles/file1.php
[includes/myphpfiles/file2.php] => includes/myphpfiles/file2.php
)