Add a class to your div, something like img1, img2, img3, etc.
Code:
div.img1 {background: url(/image1.jpg);}
div.img2 {background: url(/image2.jpg);}
div.img3 {background: url(/image3.jpg);}
Then just use the same PHP code given in this thread earlier to generate the class name instead of the image.
Code:
<div class="img<?php echo rand(0,2); ?>"></div>