You could also just store the image names in an array and refer to the array with the number. An example is the following.
<?php
function image()
{
$min = 1; //The first number one of your images has
$max = 3; //The highest number you image has
$num = rand($min, $max);
//set picture names
$pic[1]='firstpic.jpg';
$pic[2]='secondpic.jpg';
$pic[3]='another_name.jpg';
//end of setting picture names
$url = "http://website.com/~ub/_ubr/wp-content/themes/ubcmi/images/icons/" .$pic[$num]."; //change the url to your url //for the image split the url into two parts by separating in between the image name and //extension
echo "<img src='$url'>";
}
?>
Very basic and hope it does the job.
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
arrays is a good idea, but then requires alot of manuel work, of constantly updating the code when there is a new image. Unless you do it atuomaticaly but your script does not support that.
What I posted was just what the user wanted. However, there are 2 alternative options. There is the option of php automatically detecting the pictures in the folder and assign them to an array (requires a bit of cpu) or another option is to fetch the arrays from a mysql database.
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259