Created
July 13, 2018 01:05
-
-
Save sabotawsh/abdcb5945481d8edc2eff32ecdef36cc to your computer and use it in GitHub Desktop.
Random image background generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$bg = array('bg-01.jpg', 'bg-02.jpg', 'bg-03.jpg', 'bg-04.jpg', 'bg-05.jpg', 'bg-06.jpg', 'bg-07.jpg' ); // array of filenames | |
$i = rand(0, count($bg)-1); // generate random number size of the array | |
$selectedBg = "$bg[$i]"; // set variable equal to which random filename was chosen | |
?> | |
<style type="text/css"> | |
<!-- | |
body{ | |
background: url(images/<?php echo $selectedBg; ?>) no-repeat; | |
} | |
--> | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment