mima Posted May 16, 2006 Share Posted May 16, 2006 HelloLets say I'm in catalogue /home/user1/cat1/Can I in any way using PHP find every catalogue "after" cat1 i.e /home/user1/cat1/cat11/home/user1/cat1/cat12/home/user1/cat1/cat13and all files in every catalogue?I want to be able to create a menu system that the user just by adding a catalogue or file will add an item to current menu.Thanks!/MiMa Quote Link to comment https://forums.phpfreaks.com/topic/9770-find-filescatalogues-recursive/ Share on other sites More sharing options...
zq29 Posted May 16, 2006 Share Posted May 16, 2006 This method isn't properly recursive, but it will get what you want I think... [code]<?php$handle = opendir("home/user1/cat1/");while (false !== ($file = readdir($handle))) { echo "$file<br/>"; if(!strpos($file,".")) { echo "<ul>"; foreach(glob("home/user1/cat1/$file/*.*") as $content) { echo "<li>$content</li>"; } echo "</ul>"; }}closedir($handle);?>[/code]Untested, so you might need to tweak it a bit, but is that the kinda thing you wanted to do? Quote Link to comment https://forums.phpfreaks.com/topic/9770-find-filescatalogues-recursive/#findComment-36186 Share on other sites More sharing options...
mima Posted May 16, 2006 Author Share Posted May 16, 2006 I think so, I'm not to familiar with PHP syntax (strpos,strpos)But the logic seems to work for me.Thanks!Regards/MiMa[!--quoteo(post=374230:date=May 16 2006, 04:12 AM:name=SemiApocalyptic)--][div class=\'quotetop\']QUOTE(SemiApocalyptic @ May 16 2006, 04:12 AM) [snapback]374230[/snapback][/div][div class=\'quotemain\'][!--quotec--]This method isn't properly recursive, but it will get what you want I think... [code]<?php$handle = opendir("home/user1/cat1/");while (false !== ($file = readdir($handle))) { echo "$file<br/>"; if(!strpos($file,".")) { echo "<ul>"; foreach(glob("home/user1/cat1/$file/*.*") as $content) { echo "<li>$content</li>"; } echo "</ul>"; }}closedir($handle);?>[/code]Untested, so you might need to tweak it a bit, but is that the kinda thing you wanted to do?[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/9770-find-filescatalogues-recursive/#findComment-36196 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.