hi.i am new here and new to php.this is my first post and hope u help me ok.here is script that scans mp3/ dir on server and creates files and folder list and write it in xml file(music.xml) and after that this xml reads flash and creats file and folder list on site. but this script scans all file tupes on server but i want to ignor some file tupes like *.db *.jpg and other and can someone help me to modifi this php script to ignore file tupes that i want here is it <?php // http://codingforums.com/showthread.php?t=71882 function getDirectory( $path = '.', $level = 1 ){ // Directories to ignore when listing output. Many hosts // will deny PHP access to the cgi-bin. $ignore = array( 'cgi-bin', '.', '..', "_notes" ); // Open the directory to the handle $dh $dh = @opendir( $path ); // Loop through the directory while( false !== ( $file = readdir( $dh ) ) ){ // Check that this file is not to be ignored if( !in_array( $file, $ignore ) ){ // Just to add spacing to the list, to better show the directory tree. $spaces = str_repeat( ' ', ( $level * 5 ) ); // Its a directory, so we need to keep reading down... if( is_dir( "$path/$file" ) ){ $x.= $spaces . "<artist label=\"$file\" >\n"; // Re-call this same function but on a new directory. // this is what makes function recursive. $x.= getDirectory( "$path/$file", ($level+1) ); $x.= $spaces . "</artist>\n"; } else { // Just print out the filename $x.= $spaces . "<song url=\"$path/$file\" label=\"" . $file . "\" />\n"; } } } closedir( $dh ); // Close the directory handle return $x; } $dir = "mp3/"; $v= "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"; $v.= "<music>\n"; // Get the current directory $v.= getDirectory($dir); $v.= "</music>" ; $filename = "music.xml"; if (is_writable($filename)) { if (!$handle = fopen($filename, 'w')) { exit; } if (fwrite($handle, $v) === false) { exit; } fclose($handle); }else echo "Can not edit the file"; ?> PHP: thank u and sorry for my english
You could change the if (!in_array($file, $ignore)) to something like if (in_array($file, $filetypes)) and have the array $filetypes have file types you want.