Last active
August 13, 2019 13:00
-
-
Save bwonur/b70509649847cc94e26be4c4afbc20bc to your computer and use it in GitHub Desktop.
Time-delayed, two-layer switch changer function.
This file contains 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 | |
$key = array( | |
'key0', | |
'key1', | |
'key2', | |
'key3', | |
'key4', | |
'key5', | |
'key6', | |
'key7', | |
'key8', | |
'key9' | |
); | |
$keyNumber = count($key); | |
$delay = 10; | |
$time = time(); | |
$mask = array( | |
array(0 => 8, 1 => 5, 2 => 1, 3 => 9, 4 => 0, 5 => 6, 6 => 3, 7 => 2, 8 => 7, 9 => 4), | |
//0 1 2 3 4 5 6 7 8 9 | |
//8 5 1 9 0 6 3 2 7 4 | |
array(0 => 2, 1 => 4, 2 => 0, 3 => 8, 4 => 7, 5 => 1, 6 => 5, 7 => 9, 8 => 6, 9 => 3) | |
//0 1 2 3 4 5 6 7 8 9 | |
//2 4 0 8 7 1 5 9 6 3 | |
); | |
$levelOne = floor( $time / $delay ) % 2; | |
$levelTwo = floor( $time / $delay ) % $keyNumber; | |
$result = $key[$mask[$levelOne][$levelTwo]]; | |
echo $result; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment