great, makes more sense now :-)
here is my code now, but its only outputting <?xml version="1.0" encoding="utf-8"?><folder></folder> in the xml file, not the image tag, any ideas why? i think it might have something to do with the second line in the for loop?
thanks for your help with this.
<?php
$imageDir = 'gallery/';
$extensions = array('.jpg', '.jpeg', '.gif', '.swf');
if ($folder = opendir($imageDir)) {
$filenames=array();
while (false !== ($file = readdir($folder))) {
$dot = strrchr($file, '.');
$ext = substr($file, $dot);
if(in_array($ext, $extensions)){
array_push($filenames, $file);
}
}
$output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
$output .= "<folder>";
foreach ($filenames as $source) {
$imageName = str_replace("_"," ",$source);
$imageName = str_replace($extensions,"",$imageName);
$output .= "\t<image src=\"$imageDir$source\">$imageName</image>\n";
}
$output .= "</folder>";
closedir($folder);
$fp = fopen("gallery.xml", "w");
fwrite($fp, $output);
fclose($fp);
}
?>