Last updated: Fri, May 26, 2023 8:53 am
Return to Knowledgebase
Data Type | Description of Returned Data |
---|---|
array | The function returns an associative array ($row) where the keys and values are the modified file paths. The keys represent the modified file paths, and the values are identical to the keys in this case. Both keys and values are strings. |
function getPageFiles()
{
$directory = '../'; // The directory to search for PHP files
$pages = glob($directory . '*.php'); // Get all PHP files in the directory
$row = array(); // Initialize an empty array to store the modified file paths
foreach ($pages as $page) {
$fixed = str_replace('../', '/'.$us_url_root, $page); // Modify the file path
$row[$fixed] = $fixed; // Add the modified file path to the array
}
return $row; // Return the array of modified file paths
}
// Include the file containing the getPageFiles function
require_once 'path/to/getPageFiles.php';
// Call the function to get the modified file paths
$pageFiles = getPageFiles();
// Iterate over the returned array of file paths
foreach ($pageFiles as $file) {
echo $file . '
'; // Output the modified file paths
}