Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function replaceBackground() {
- $directory = "images/backgrounds"; // folder name
- $backgrounds = glob($directory . "*.jpg"); // get all .jpg files
- $random_bg = array_rand($backgrounds, 1); // select one random image
- return $backgrounds[$random_bg[0]]; // echo the path of our random image
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement