myanavrin Posted August 23, 2007 Share Posted August 23, 2007 Hello to all, I want to ask how can I list all the files and folders inside a given directory. example: C:\Documents and Settings\user11\My Documents is the directory. I want to get all the files and folders name inside it. Link to comment https://forums.phpfreaks.com/topic/66364-searching-file-in-folder/ Share on other sites More sharing options...
trq Posted August 23, 2007 Share Posted August 23, 2007 <?php $dir = scandir('C:\Documents and Settings\user11\My Documents'); foreach($dir as $file) { echo "$file<br />"; } ?> Link to comment https://forums.phpfreaks.com/topic/66364-searching-file-in-folder/#findComment-332036 Share on other sites More sharing options...
myanavrin Posted August 23, 2007 Author Share Posted August 23, 2007 thanks. Sir follow question. How about if searching for specific file type? If I would search for .html Link to comment https://forums.phpfreaks.com/topic/66364-searching-file-in-folder/#findComment-332091 Share on other sites More sharing options...
trq Posted August 23, 2007 Share Posted August 23, 2007 Even easier... <?php foreach (glob('C:\Documents and Settings\user11\My Documents\*.html') as $file) { echo "$file<br />"; } ?> Link to comment https://forums.phpfreaks.com/topic/66364-searching-file-in-folder/#findComment-332095 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.