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? Link to comment https://forums.phpfreaks.com/topic/32116-glob-question/ 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 .. Link to comment https://forums.phpfreaks.com/topic/32116-glob-question/#findComment-149032 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 Link to comment https://forums.phpfreaks.com/topic/32116-glob-question/#findComment-149113 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. Link to comment https://forums.phpfreaks.com/topic/32116-glob-question/#findComment-150058 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.