KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
i came across few articles about performance and readdir here is the php script: function getDirectory( $path = '.', $level = 0 ) { $ignore = array( 'cgi-bin', '.', '..' ); $dh = @opendir( $path ); while( false !== ( $file = readdir( $dh ) ) ){ if( !in_array( $file, $ignore ) ){ $spaces = str_repeat( ' ', ( $level * 4 ) ); if( is_dir( "$path/$file" ) ){ echo "$spaces $file\n"; getDirectory( "$path/$file", ($level+1) ); } else { echo "$spaces $file\n"; } } } closedir( $dh ); } getDirectory( "." ); this echo the files/ folders correctly. now i found this: $t = system('find'); print_r($t); which also find all the folders and files then i can create an array like the first code. i think the system('find'); is faster than the readdir but i want to know if it'S a good practice? thank you very much
Tags (comma-separated)
Save Edits
Cancel