But lets take it a bit further for this blog, to show it in a simple script. Say you want to randomise the background image on a webpage. Start of by setting up your images with a progressive name and store them in the same folder:
myImage-1.jpg myImage-2.jpg myImage-3.jpg myImage-4.jpg myImage-5.jpg

Then you can use the following simple script to dynamically set which image will appear.

rand() is a built in function in php and selects a random number between the two stated parameters, in this case it would be 1 and 5. For more info on this function you can check out the php manual http://www.php.net/manual/en/function.rand.php

w3b-Doctor Blog Terms And Conditions Of Use

All content provided on the w3b-Doctor.com blog is for informational purposes only. We makes no representations as to the accuracy or completeness of any information on this site or found by following any link on this site.

The owner of w3b-Doctor.com will not be liable for any errors or omissions in this information nor for the availability of this information. The owner will not be liable for any losses, injuries, or damages from the display or use of this information.

This terms and conditions is subject to change at anytime with or without notice.