// Generate randomness $num = rand(1,4); //make max number the number of images you have //output background $qrback = "{imagesfolders}/qrback$num.jpg";