Skip to content

Instantly share code, notes, and snippets.

@shawnfromportland
Created October 8, 2018 05:56
Show Gist options
  • Save shawnfromportland/f029e4a1ee76d7870d5dacf87e8cb3b0 to your computer and use it in GitHub Desktop.
Save shawnfromportland/f029e4a1ee76d7870d5dacf87e8cb3b0 to your computer and use it in GitHub Desktop.
// ============================================================================
// Optional:
// Select a random picture from different time-of-day sets
// selected choice is loaded into $headerImageName for use in your page
// ============================================================================
// default to the daytime set
$activePicSet = $dayPics;
switch($nowSecond){
case $nowSecond >= $sun['civil_twilight_end']:
//NIGHT TIME
$activePicSet = $nightPics;
break;
case $nowSecond <= $sun['sunrise']:
//DAWN
$activePicSet = $sunrisePics;
break;
case $nowSecond > $sun['sunset']
&&
$nowSecond < $sun['civil_twilight_end'] :
//SUNSET
$activePicSet = $sunsetPics;
break;
case $nowSecond > $sun['sunrise']
&&
$nowSecond < $sun['sunset'] :
default:
//DAY
$activePicSet = $dayPics;
break;
}
// choose at random from the active pic set
$headerImageName = $activePicSet[array_rand($activePicSet)];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment