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");
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:  29
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        INIT_FCALL                                               'substr'
         16        SEND_VAR                                                 !4
         17        SEND_VAL                                                 0
         18        SEND_VAL                                                 15
         19        DO_ICALL                                         $17     
         20        SEND_VAR                                                 $17
         21        DO_ICALL                                         $18     
         22        MOD                                              ~19     $18, !3
         23        ADD                                              ~20     ~19, 1
         24        ASSIGN                                                   !5, ~20
   11    25        NOP                                                      
         26        FAST_CONCAT                                      ~22     'Winning+ticket%3A+', !5
         27        ECHO                                                     ~22
         28      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.42 ms | 1012 KiB | 16 Q