The Little Guy Posted December 28, 2006 Share Posted December 28, 2006 How can I glob folders in a directory, then get the folders within those folders and folders within those folders, and so on? Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted December 28, 2006 Share Posted December 28, 2006 use a recursive function to traverse the tree tructure and chek if the current file is_dir.make sure you account for . and .. Quote Link to comment Share on other sites More sharing options...
printf Posted December 29, 2006 Share Posted December 29, 2006 An example without bad recursion![code]<?$base = array ( './www/' );$keep = array ();while ( ! empty ( $base ) ){ $next = array_pop ( $base ); foreach ( glob ( $next . '*' ) AS $directory ) { if ( is_dir ( $directory ) ) { $base[] = $directory . '/'; $keep[] = $directory . '/'; } }}print_r ( $keep );?>[/code]printf Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted December 30, 2006 Author Share Posted December 30, 2006 All I get is an empty array. Quote Link to comment 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.