3v4l.org

run code in 300+ PHP versions simultaneously
<?php $server_seed = "96f3e04d221ca1b2048cc3b3b844e479f2bd9c80a870628072ee98fd1aa83cd0"; // make sure to use non-hashed server seed $public_seed = "20charlongstringxxxxx"; $battle_id = "546"; $tie_breaker_player_count = 2;// how many players have opened the same amount $hash = hash('sha256', $server_seed . "-" . $public_seed . "-" . $battle_id . "case-battle-tie-braker"); $winning_player = hexdec(substr($hash, 0, 15)) % $tie_breaker_player_count + 1; // $winning_player represents which player won out of those that opened the same amount. // if player 1 and 3 open the same and we have to determine which one from these wins, if $winning_player = 1, player 1 wins, if $winning_player = 2, player 3 wins echo("Winning ticket: $winning_player");
Output for 8.1.28 - 8.1.33, 8.2.17 - 8.2.29, 8.3.4 - 8.3.28, 8.4.1 - 8.4.14, 8.4.16, 8.5.0 - 8.5.1
Winning ticket: 1
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
93.21 ms | 407 KiB | 5 Q