Array ( [0] => . [1] => .. [2] => bg2.gif [3] => bg3.gif [4] => bg4.gif [5] => bg5.gif [6] => bg6.gif [7] => bg7.gif [8] => bg8.gif [9] => bg9.gif )
:-)
I used a separate folder named bgfolder to store my images $bgdir = 'bgfolder'; next we need a way to conveniently access those images, so we'll reference them in an array with scandir function now we'll randomly generate an index. we need a value between 0 and number of images. if we count the number of elements inside the bgarr array using count() function, the size is bigger than the number of images. thats because scandir() includes the directory itself (/.)and the parent directory (/..). they are the first two elements of an array. so our rand() range has to be from 2 to size of bgarr. rand(min, max) min = 2 max = count($bgarr)-1 (-1 because the range is inclusive) rand(2, count($bgarr)-1) I'm short on time right now but I will remake the content of this page so it's more readable. maybe someone will find it useful idk