This is the way I list my folder’s folders [ only folder ]:
foreach(glob('k:\\thousandoffolders\\*', GLOB_ONLYDIR) as $folders){
echo basename($folders).' '; // get folder's name
}
So,is it the right way!?
And my purpose is to get all folder's name which inside special folder and store them in the database MySQL.E.g:
drives with special folders:
D:\folderContainer
E:\folderContainer
...
H:\folderContainer
and every folderContainer may be contain thousands of folders.And I just want to go through all the folderContainers and get all folders’ name then store inside MySQL.And if folder’s name exist in database the MySQL could return it to notice and continue store next one.
Thank you very much!!
Is there a reason why
scandiris not used? Regular expressions thatglob()uses are not very efficient. I’d go with:Update
In response to comments, I ran a test to see what the actual performance gains are.
According to results it took over 1.5 seconds for
glob()to burn through 10 000 directories whilescandir()completed the same task in 0.2 seconds. That is 700% faster.