//put names of all images you want to rotate randomly
$image_set=array("img1.jpg","img2.jpg","img3.jpg","img4.jpg");
//now select any one random image
$randomly_selected_image=$image_set[array_rand($image_set,1)];
//now fetch the image and store it in a string
$image=file_get_contents("images/$randomly_selected_image");
//send a header to the browser telling it that we are now sending an image
header("Content-type: image/jpg");
//now send the image.
echo $image;
/*
Because we informed the browser earlier that we are sending an image, it could parse that string as an image.
Else it gets confused and parses it as plain text which looks horrible(with all question marks and rhombuses and weird characters-like the one when fonts are missing!)
*/