After a little help I have this recursive function that does its job well, however I need it to create me a link to files.
At the moment the function can only store $dir/$file.php and I need it to create the full path as it loops.
function siteMap($dir){
$scan = scandir($dir);
foreach ($scan as $file) {
if ($file === '.' or $file === '..' or $file === '.DS_Store') continue;
echo '<a href="../' . $file . '">' . $file . '</a><br>';
if (is_dir($dir . '/' . $file)) {
siteMap($dir . '/' . $file);
}
}
}
siteMap('application/view');
as you can see this will loop through all the folders and files in a directory and print it to the screen via a link. i will try and include my file structure.
-root(application/view)
--site[+]
---about.php
---new.php
--product[+]
---view.php
---all.php
---search.php
I want to basically create a dynamic site map so every time a new dir or file added it will be included in the site map, this needs to print the parent dir and the content file as a link.