3v4l.org

run code in 300+ PHP versions simultaneously
<?php function roll() { return rand(1, 6) + rand(1, 6); } $roller1 = []; $roller2 = []; $totalRolls = 1; for ($i = 0; $i < $totalRolls; ++$i) { $roller1[] = roll(); $roller2[] = roll(); } $map = array_count_values($roller1); echo "roller1 =\n" . var_export($roller1, true); echo "\n\nroller2 =\n" . var_export($roller2, true); echo "\n\nmap =\n" . var_export($map, true); $outcome = 'Lucky'; foreach ($roller2 as $roll) { echo "\n\tchecking: $roll"; if (!empty($map[$roll])) { --$map[$roll]; } else { $outcome = 'Unlucky'; break; } } echo "\n\noutcome = $outcome";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 5
Branch analysis from position: 16
2 jumps found. (Code = 77) Position 1 = 40, Position 2 = 53
Branch analysis from position: 40
2 jumps found. (Code = 78) Position 1 = 41, Position 2 = 53
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 50
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 52
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 53
Branch analysis from position: 53
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 5
Branch analysis from position: 16
Branch analysis from position: 5
filename:       /in/FiXKa
function name:  (null)
number of ops:  58
compiled vars:  !0 = $roller1, !1 = $roller2, !2 = $totalRolls, !3 = $i, !4 = $map, !5 = $outcome, !6 = $roll
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ASSIGN                                                   !0, <array>
    7     1        ASSIGN                                                   !1, <array>
    8     2        ASSIGN                                                   !2, 1
   10     3        ASSIGN                                                   !3, 0
          4      > JMP                                                      ->14
   11     5    >   INIT_FCALL                                               'roll'
          6        DO_FCALL                                      0  $12     
          7        ASSIGN_DIM                                               !0
          8        OP_DATA                                                  $12
   12     9        INIT_FCALL                                               'roll'
         10        DO_FCALL                                      0  $14     
         11        ASSIGN_DIM                                               !1
         12        OP_DATA                                                  $14
   10    13        PRE_INC                                                  !3
         14    >   IS_SMALLER                                               !3, !2
         15      > JMPNZ                                                    ~16, ->5
   15    16    >   INIT_FCALL                                               'array_count_values'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $17     
         19        ASSIGN                                                   !4, $17
   17    20        INIT_FCALL                                               'var_export'
         21        SEND_VAR                                                 !0
         22        SEND_VAL                                                 <true>
         23        DO_ICALL                                         $19     
         24        CONCAT                                           ~20     'roller1+%3D%0A', $19
         25        ECHO                                                     ~20
   18    26        INIT_FCALL                                               'var_export'
         27        SEND_VAR                                                 !1
         28        SEND_VAL                                                 <true>
         29        DO_ICALL                                         $21     
         30        CONCAT                                           ~22     '%0A%0Aroller2+%3D%0A', $21
         31        ECHO                                                     ~22
   19    32        INIT_FCALL                                               'var_export'
         33        SEND_VAR                                                 !4
         34        SEND_VAL                                                 <true>
         35        DO_ICALL                                         $23     
         36        CONCAT                                           ~24     '%0A%0Amap+%3D%0A', $23
         37        ECHO                                                     ~24
   21    38        ASSIGN                                                   !5, 'Lucky'
   22    39      > FE_RESET_R                                       $26     !1, ->53
         40    > > FE_FETCH_R                                               $26, !6, ->53
   23    41    >   NOP                                                      
         42        FAST_CONCAT                                      ~27     '%0A%09checking%3A+', !6
         43        ECHO                                                     ~27
   24    44        ISSET_ISEMPTY_DIM_OBJ                         1  ~28     !4, !6
         45        BOOL_NOT                                         ~29     ~28
         46      > JMPZ                                                     ~29, ->50
   25    47    >   FETCH_DIM_RW                                     $30     !4, !6
         48        PRE_DEC                                                  $30
   24    49      > JMP                                                      ->52
   27    50    >   ASSIGN                                                   !5, 'Unlucky'
   28    51      > JMP                                                      ->53
   22    52    > > JMP                                                      ->40
         53    >   FE_FREE                                                  $26
   32    54        NOP                                                      
         55        FAST_CONCAT                                      ~33     '%0A%0Aoutcome+%3D+', !5
         56        ECHO                                                     ~33
         57      > RETURN                                                   1

Function roll:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FiXKa
function name:  roll
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'rand'
          1        SEND_VAL                                                 1
          2        SEND_VAL                                                 6
          3        DO_ICALL                                         $0      
          4        INIT_FCALL                                               'rand'
          5        SEND_VAL                                                 1
          6        SEND_VAL                                                 6
          7        DO_ICALL                                         $1      
          8        ADD                                              ~2      $0, $1
          9      > RETURN                                                   ~2
    4    10*     > RETURN                                                   null

End of function roll

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.68 ms | 1007 KiB | 18 Q