list - How to get name of directory (NOT subdirectory) and filename with PHP? -
i have following folder structure. want names of directories (not subdirectories) , files. how can php? thank you.
main directory directory1 subdirectory1 file1 file2 subdirectory2 file3 file4 directory2 subdirectory3 file5 file6 subdirectory4 file7 file8
result should that:
directory: directory1 file: file1 file: file2 directory: directory2 file: file3 file: file4
try directoryiterator,here example
$path = dirname(dirname(__file__)); $it = new directoryiterator($path); while($it->valid()){ /*....*/ echo $it->getpathname().'">'.$it->getbasename(); $it->next();//i forgot }
Comments
Post a Comment