Random File list with PHP


I have been scratching my head trying to figure this out… sadly I haven’t. I’m sure this is something simple; please help me out.

using PHP I would like to list all the files in a specified folder in a random sequence. And output this as an xml file. Here’s what I have so far…

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>

echo "<songs>


	while ($file=readdir($dir))
		if ($file != "." && $file != "..")
			list($name, $ext) = explode(".", $file);
			list($artist, $title) = explode("-", $name);
			echo "<song path=\"".$file."\" artist=\"".$artist."\" title= \"".$title."\"></song>

echo "</songs>

How can I modify this to generate a random list.