<?php
$dir = opendir("/");
while ($entry = readdir($dir))
{
$filelist[$num] = $entry;
$num++;
}
closedir($dir);
// start at 2 to get rid of '.' and '..'
for ($i = 2; $i < $num; $i++)
{
if ((substr($filelist[$i], (strlen($filelist[$i]) - 3), 3) == "gif") || (substr($filelist[$i], (strlen($filelist[$i]) - 3), 3) == "jpg"))
{
$randimg[$x] = $filelist[$i];
$x++;
}
}
?>
try that. it should work the way you want.