# Php file tupes help

**URL:** https://forum.kirupa.com/t/php-file-tupes-help/247848
**Category:** Uncategorized
**Created:** [December 30, 2007, 11:40pm UTC](https://forum.kirupa.com/t/php-file-tupes-help/247848 "2007-12-30T23:40:26Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![nnnswordfish](https://avatars.discourse-cdn.com/v4/letter/n/65b543/32.png) [@nnnswordfish](https://forum.kirupa.com/u/nnnswordfish)
#### Post date: [December 30, 2007, 11:40pm UTC](https://forum.kirupa.com/t/php-file-tupes-help/247848/1 "2007-12-30T23:40:26Z")

</div>

this php script scan mp3/a dir and creates xml file that reads flash and flash creats list of files and folders but it only wach(scan) mp3 files,but i want to scan any file tupe with this script how i can do this :)?

```php
<?php
$dir = "mp3/a/";

echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>
";
echo "<music>
";

// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
         $subdir = $file;         
         if ($subdir != "." && $subdir != ".." && $subdir != "_notes") {
            echo "<artist label=\"$subdir\" >
";
            //Scan the subdirectories
            if ($sh = opendir($dir . $subdir."/")) {
               while (($sfile = readdir($sh)) !== false) {
               if ($sfile != "." && $sfile != "..") {
                  $pos = strrpos($sfile, ".mp3");
                  
                  if ($pos) {
                     $subfile = $sfile;
                     echo "<song url=\"$dir$subdir/$subfile\" label=\"" . str_replace(".mp3","",$subfile) . "\" />
";
                }
                  
                  }
                  
               }
               closedir($sh);
            
            }
            echo "</artist>
";         
         
         }         
         
        }
        closedir($dh);
    } 
}
echo "</music>"
?>

```
