Hi,
I have written a script which reads files from a directory to build an xml file. Everything works great exepct on the mac, hidden files are included in the final output. is there any way to filter these out?
<?php
$imageDir = '../mp3/';
$extensions = array(".mp3", ".MP3", ".wav",".WAV");
if ($folder = opendir($imageDir)) {
$filenames=array();
while (false !== ($file = readdir($folder))) {
$dot = strrchr($file, '.');
if(in_array($dot, $extensions)){
array_push($filenames, $file);
}
}
$output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
$output .= "<songs>\n";
foreach ($filenames as $source) {
$newPath = str_replace("../","",$imageDir);
$imageName = str_replace("_"," ",$source);
$imageName = str_replace($extensions,"",$imageName);
$output .= "\t<song src=\"$newPath$source\">$imageName</song>\n";
}
$output .= "</songs>";
closedir($folder);
$fp = fopen("../xml/musicPlayer/songs.xml", "w");
fwrite($fp, $output);
fclose($fp);
}
?>
thanks,
Gareth