Dear PHP-Programmer,
I have a PHP script which select randomly a image from a folder called" bilder", the script has the name sabine3.php and it is the following:
<?php function getRandomImage($dir,$type='random') { global $errors,$seed; if (is_dir($dir)) { $fd = opendir($dir); $images = array(); while (($part = @readdir($fd)) == true) { if ( eregi("(gif|jpg|png|jpeg)$",$part) ) { $images[] = $part; } } // adding this in case you want to return the image array if ($type == 'all') return $images; if ($seed !== true) { mt_srand ((double) microtime() * 1000000); $seed = true; } $key = mt_rand (0,sizeof($images)-1); return $dir . $images[$key]; } else { $errors[] = $dir.' is not a directory'; return false; } } $image = getRandomImage('bilder/'); echo "The script is OK but I want to create a HTM-page where I can show the random image, I wrote this HTM-Code:
Untitled DocumentBut it doesn´t work, so how can I show the image???
Thank you,
frank