However, if your image names are not in consecutive number format (or in a number format at all), you'll have to loop through every file, add the name to an array, then pick a random key from the array.
<?php
$dir = opendir("./images/");
while ($file = readdir($dir)) {
$filearray[] = $file;
}
closedir($dir);
$randnum = rand(0,count($filearray));
echo("<img src=\"".$filearray[$randnum]."\">");
?>
And there you have it. Most everything is self-explanatory.