3v4l.org

run code in 300+ PHP versions simultaneously
<?php $options = array_flip(['paper', 'rock', 'scissors']); $outcomes = ['draw', 'win', 'lose']; $cpuSelection = array_rand($options); $playerSelection = 'rock'; $difference = $options[$cpuSelection] - $options[$playerSelection]; var_export([ 'cpu' => $cpuSelection, 'human' => $playerSelection, 'outcome' => $outcomes[($difference + 3) % 3] ]);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kcR45
function name:  (null)
number of ops:  24
compiled vars:  !0 = $options, !1 = $outcomes, !2 = $cpuSelection, !3 = $playerSelection, !4 = $difference
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'array_flip'
          1        SEND_VAL                                                 <array>
          2        DO_ICALL                                         $5      
          3        ASSIGN                                                   !0, $5
    4     4        ASSIGN                                                   !1, <array>
    6     5        INIT_FCALL                                               'array_rand'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $8      
          8        ASSIGN                                                   !2, $8
    7     9        ASSIGN                                                   !3, 'rock'
    8    10        FETCH_DIM_R                                      ~11     !0, !2
         11        FETCH_DIM_R                                      ~12     !0, !3
         12        SUB                                              ~13     ~11, ~12
         13        ASSIGN                                                   !4, ~13
   10    14        INIT_FCALL                                               'var_export'
   11    15        INIT_ARRAY                                       ~15     !2, 'cpu'
   12    16        ADD_ARRAY_ELEMENT                                ~15     !3, 'human'
   13    17        ADD                                              ~16     !4, 3
         18        MOD                                              ~17     ~16, 3
         19        FETCH_DIM_R                                      ~18     !1, ~17
         20        ADD_ARRAY_ELEMENT                                ~15     ~18, 'outcome'
         21        SEND_VAL                                                 ~15
         22        DO_ICALL                                                 
   14    23      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.35 ms | 1395 KiB | 19 Q