I found this code from http://kevin.vanzonneveld.net/techblog/article/convert_anything_to_tree_structures_in_php/, but I couldn’t get it work. I am working on WIndow environment and the path I use is /sellable where the sellable is the folder inside the working folder :
if(exec("find /etc/php5", $files)){
// the $files array now holds the path as it's values,
// but we also want the paths as keys:
$key_files = array_combine(array_values($files), array_values($files));
// show the array
print_r($key_files);
}
Can anyone help me ?
findis a Linux command (an external Linux program).Which means it will not be present on windows…
And
/etc/php5really looks like an UNIX path to a directory ; and doesn’t look like a path to a Windows directory.So, two problems here :
find.But I’d say that a PHP-only solution would probably be better : there are functions and classes that will allow you to search files and iterate over the filesystem — and it would work on both Linux and Windows, not depending on any external program.
For instance, to iterate over a directory, you might want to take a look to the
RecursiveDirectoryIteratorclass — and maybe alsoDirectoryIterator.