3v4l.org

run code in 500+ 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");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nlMtE
function name:  (null)
number of ops:  26
compiled vars:  !0 = $server_seed, !1 = $public_seed, !2 = $battle_id, !3 = $tie_breaker_player_count, !4 = $hash, !5 = $winning_player
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '96f3e04d221ca1b2048cc3b3b844e479f2bd9c80a870628072ee98fd1aa83cd0'
    4     1        ASSIGN                                                       !1, '20charlongstringxxxxx'
    5     2        ASSIGN                                                       !2, '546'
    6     3        ASSIGN                                                       !3, 2
    7     4        INIT_FCALL                                                   'hash'
          5        SEND_VAL                                                     'sha256'
          6        CONCAT                                               ~10     !0, '-'
          7        CONCAT                                               ~11     ~10, !1
          8        CONCAT                                               ~12     ~11, '-'
          9        CONCAT                                               ~13     ~12, !2
         10        CONCAT                                               ~14     ~13, 'case-battle-tie-braker'
         11        SEND_VAL                                                     ~14
         12        DO_ICALL                                             $15     
         13        ASSIGN                                                       !4, $15
    8    14        INIT_FCALL                                                   'hexdec'
         15        FRAMELESS_ICALL_3                substr              ~17     !4, 0
         16        OP_DATA                                                      15
         17        SEND_VAL                                                     ~17
         18        DO_ICALL                                             $18     
         19        MOD                                                  ~19     $18, !3
         20        ADD                                                  ~20     ~19, 1
         21        ASSIGN                                                       !5, ~20
   11    22        NOP                                                          
         23        FAST_CONCAT                                          ~22     'Winning+ticket%3A+', !5
         24        ECHO                                                         ~22
         25      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
206.56 ms | 1458 KiB | 15 Q