3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = "1 AND 2 -> a"; $inputs = explode("\n", $input); function operation($s){ $matchesand = null; $and = preg_match("/(.{1,2})\sAND\s(.{1,2})\s->\s(.{1,2})/",$s,$matchesand); if(count($matchesand)>0){ return [1,$matchesand[1] , $matchesand[2], $matchesand[3]]; } $matchesor= null; $or = preg_match("/(.{1,2})\sOR\s(.{1,2})\s->\s(.{1,2})/",$s,$matchesor); if(count($matchesor)>0){ return [2,$matchesor[1] , $matchesor[2], $matchesor[3]]; } $matchesnot = null; $not = preg_match("/NOT\s(.{1,2})\s->\s(.{1,2})/",$s,$matchesnot); if(count($matchesnot)>0){ return [3,$matchesnot[1], $matchesnot[2]]; } $matchesleft = null; $left = preg_match("/(.{1,2})\sLSHIFT\s(.{1,2})\s->\s(.{1,2})/",$s,$matchesleft); if(count($matchesleft)>0){ return [4,$matchesleft[1] , $matchesleft[2], $matchesleft[3]]; } $matchesright = null; $right = preg_match("/(.{1,2})\sRSHIFT\s(.{1,2})\s->\s(.{1,2})/",$s,$matchesright); if(count($matchesright)>0){ return [5,$matchesright[1] , $matchesright[2], $matchesright[3]]; } $matches = null; $simple = preg_match("/(.{1,5})\s->\s(.{1,2})/",$s,$matches); if(count($matches)>0){ return [6,$matches[1], $matches[2]]; } } $array=[]; for($i = 'a'; $i<'z'; $i++){ $array[$i]=0; } for($i = 'a'; $i<'z'; $i++){ for($j = 'a'; $j<'z'; $j++){ $array[$i.$j]=0; } } for($i = 0; $i<count($inputs); $i++){ $values = operation($inputs[i]); if($operation[0] === 1){ $array[$values[3]] = $array[$values[1]] & $array[$values[2]]; } $array[$var] = $val; } var_dump($array); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 9
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 16
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
2 jumps found. (Code = 44) Position 1 = 52, Position 2 = 29
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 46
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 52, Position 2 = 29
Branch analysis from position: 52
Branch analysis from position: 29
Branch analysis from position: 46
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 18
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 16
Branch analysis from position: 27
Branch analysis from position: 16
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 18
Branch analysis from position: 24
Branch analysis from position: 18
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 9
Branch analysis from position: 14
Branch analysis from position: 9
filename:       /in/uXkjt
function name:  (null)
number of ops:  56
compiled vars:  !0 = $input, !1 = $inputs, !2 = $array, !3 = $i, !4 = $j, !5 = $values, !6 = $operation, !7 = $var, !8 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '1+AND+2+-%3E+a'
    3     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%0A'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $10     
          5        ASSIGN                                                   !1, $10
   41     6        ASSIGN                                                   !2, <array>
   42     7        ASSIGN                                                   !3, 'a'
          8      > JMP                                                      ->12
   43     9    >   ASSIGN_DIM                                               !2, !3
         10        OP_DATA                                                  0
   42    11        PRE_INC                                                  !3
         12    >   IS_SMALLER                                               !3, 'z'
         13      > JMPNZ                                                    ~16, ->9
   45    14    >   ASSIGN                                                   !3, 'a'
         15      > JMP                                                      ->25
   46    16    >   ASSIGN                                                   !4, 'a'
         17      > JMP                                                      ->22
   47    18    >   CONCAT                                           ~19     !3, !4
         19        ASSIGN_DIM                                               !2, ~19
         20        OP_DATA                                                  0
   46    21        PRE_INC                                                  !4
         22    >   IS_SMALLER                                               !4, 'z'
         23      > JMPNZ                                                    ~22, ->18
   45    24    >   PRE_INC                                                  !3
         25    >   IS_SMALLER                                               !3, 'z'
         26      > JMPNZ                                                    ~24, ->16
   50    27    >   ASSIGN                                                   !3, 0
         28      > JMP                                                      ->49
   51    29    >   INIT_FCALL                                               'operation'
         30        FETCH_CONSTANT                                   ~26     'i'
         31        FETCH_DIM_R                                      ~27     !1, ~26
         32        SEND_VAL                                                 ~27
         33        DO_FCALL                                      0  $28     
         34        ASSIGN                                                   !5, $28
   52    35        FETCH_DIM_R                                      ~30     !6, 0
         36        IS_IDENTICAL                                             ~30, 1
         37      > JMPZ                                                     ~31, ->46
   53    38    >   FETCH_DIM_R                                      ~32     !5, 3
         39        FETCH_DIM_R                                      ~34     !5, 1
         40        FETCH_DIM_R                                      ~35     !2, ~34
         41        FETCH_DIM_R                                      ~36     !5, 2
         42        FETCH_DIM_R                                      ~37     !2, ~36
         43        BW_AND                                           ~38     ~35, ~37
         44        ASSIGN_DIM                                               !2, ~32
         45        OP_DATA                                                  ~38
   56    46    >   ASSIGN_DIM                                               !2, !7
         47        OP_DATA                                                  !8
   50    48        PRE_INC                                                  !3
         49    >   COUNT                                            ~41     !1
         50        IS_SMALLER                                               !3, ~41
         51      > JMPNZ                                                    ~42, ->29
   58    52    >   INIT_FCALL                                               'var_dump'
         53        SEND_VAR                                                 !2
         54        DO_ICALL                                                 
   59    55      > RETURN                                                   1

Function operation:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 19
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 37
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 53
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 53
2 jumps found. (Code = 43) Position 1 = 63, Position 2 = 71
Branch analysis from position: 63
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 71
2 jumps found. (Code = 43) Position 1 = 81, Position 2 = 89
Branch analysis from position: 81
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 89
2 jumps found. (Code = 43) Position 1 = 99, Position 2 = 105
Branch analysis from position: 99
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 105
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uXkjt
function name:  operation
number of ops:  106
compiled vars:  !0 = $s, !1 = $matchesand, !2 = $and, !3 = $matchesor, !4 = $or, !5 = $matchesnot, !6 = $not, !7 = $matchesleft, !8 = $left, !9 = $matchesright, !10 = $right, !11 = $matches, !12 = $simple
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        ASSIGN                                                   !1, null
    7     2        INIT_FCALL                                               'preg_match'
          3        SEND_VAL                                                 '%2F%28.%7B1%2C2%7D%29%5CsAND%5Cs%28.%7B1%2C2%7D%29%5Cs-%3E%5Cs%28.%7B1%2C2%7D%29%2F'
          4        SEND_VAR                                                 !0
          5        SEND_REF                                                 !1
          6        DO_ICALL                                         $14     
          7        ASSIGN                                                   !2, $14
    8     8        COUNT                                            ~16     !1
          9        IS_SMALLER                                               0, ~16
         10      > JMPZ                                                     ~17, ->19
    9    11    >   INIT_ARRAY                                       ~18     1
         12        FETCH_DIM_R                                      ~19     !1, 1
         13        ADD_ARRAY_ELEMENT                                ~18     ~19
         14        FETCH_DIM_R                                      ~20     !1, 2
         15        ADD_ARRAY_ELEMENT                                ~18     ~20
         16        FETCH_DIM_R                                      ~21     !1, 3
         17        ADD_ARRAY_ELEMENT                                ~18     ~21
         18      > RETURN                                                   ~18
   12    19    >   ASSIGN                                                   !3, null
   13    20        INIT_FCALL                                               'preg_match'
         21        SEND_VAL                                                 '%2F%28.%7B1%2C2%7D%29%5CsOR%5Cs%28.%7B1%2C2%7D%29%5Cs-%3E%5Cs%28.%7B1%2C2%7D%29%2F'
         22        SEND_VAR                                                 !0
         23        SEND_REF                                                 !3
         24        DO_ICALL                                         $23     
         25        ASSIGN                                                   !4, $23
   14    26        COUNT                                            ~25     !3
         27        IS_SMALLER                                               0, ~25
         28      > JMPZ                                                     ~26, ->37
   15    29    >   INIT_ARRAY                                       ~27     2
         30        FETCH_DIM_R                                      ~28     !3, 1
         31        ADD_ARRAY_ELEMENT                                ~27     ~28
         32        FETCH_DIM_R                                      ~29     !3, 2
         33        ADD_ARRAY_ELEMENT                                ~27     ~29
         34        FETCH_DIM_R                                      ~30     !3, 3
         35        ADD_ARRAY_ELEMENT                                ~27     ~30
         36      > RETURN                                                   ~27
   18    37    >   ASSIGN                                                   !5, null
   19    38        INIT_FCALL                                               'preg_match'
         39        SEND_VAL                                                 '%2FNOT%5Cs%28.%7B1%2C2%7D%29%5Cs-%3E%5Cs%28.%7B1%2C2%7D%29%2F'
         40        SEND_VAR                                                 !0
         41        SEND_REF                                                 !5
         42        DO_ICALL                                         $32     
         43        ASSIGN                                                   !6, $32
   20    44        COUNT                                            ~34     !5
         45        IS_SMALLER                                               0, ~34
         46      > JMPZ                                                     ~35, ->53
   21    47    >   INIT_ARRAY                                       ~36     3
         48        FETCH_DIM_R                                      ~37     !5, 1
         49        ADD_ARRAY_ELEMENT                                ~36     ~37
         50        FETCH_DIM_R                                      ~38     !5, 2
         51        ADD_ARRAY_ELEMENT                                ~36     ~38
         52      > RETURN                                                   ~36
   24    53    >   ASSIGN                                                   !7, null
   25    54        INIT_FCALL                                               'preg_match'
         55        SEND_VAL                                                 '%2F%28.%7B1%2C2%7D%29%5CsLSHIFT%5Cs%28.%7B1%2C2%7D%29%5Cs-%3E%5Cs%28.%7B1%2C2%7D%29%2F'
         56        SEND_VAR                                                 !0
         57        SEND_REF                                                 !7
         58        DO_ICALL                                         $40     
         59        ASSIGN                                                   !8, $40
   26    60        COUNT                                            ~42     !7
         61        IS_SMALLER                                               0, ~42
         62      > JMPZ                                                     ~43, ->71
   27    63    >   INIT_ARRAY                                       ~44     4
         64        FETCH_DIM_R                                      ~45     !7, 1
         65        ADD_ARRAY_ELEMENT                                ~44     ~45
         66        FETCH_DIM_R                                      ~46     !7, 2
         67        ADD_ARRAY_ELEMENT                                ~44     ~46
         68        FETCH_DIM_R                                      ~47     !7, 3
         69        ADD_ARRAY_ELEMENT                                ~44     ~47
         70      > RETURN                                                   ~44
   29    71    >   ASSIGN                                                   !9, null
   30    72        INIT_FCALL                                               'preg_match'
         73        SEND_VAL                                                 '%2F%28.%7B1%2C2%7D%29%5CsRSHIFT%5Cs%28.%7B1%2C2%7D%29%5Cs-%3E%5Cs%28.%7B1%2C2%7D%29%2F'
         74        SEND_VAR                                                 !0
         75        SEND_REF                                                 !9
         76        DO_ICALL                                         $49     
         77        ASSIGN                                                   !10, $49
   31    78        COUNT                                            ~51     !9
         79        IS_SMALLER                                               0, ~51
         80      > JMPZ                                                     ~52, ->89
   32    81    >   INIT_ARRAY                                       ~53     5
         82        FETCH_DIM_R                                      ~54     !9, 1
         83        ADD_ARRAY_ELEMENT                                ~53     ~54
         84        FETCH_DIM_R                                      ~55     !9, 2
         85        ADD_ARRAY_ELEMENT                                ~53     ~55
         86        FETCH_DIM_R                                      ~56     !9, 3
         87        ADD_ARRAY_ELEMENT                                ~53     ~56
         88      > RETURN                                                   ~53
   35    89    >   ASSIGN                                                   !11, null
   36    90        INIT_FCALL                                               'preg_match'
         91        SEND_VAL                                                 '%2F%28.%7B1%2C5%7D%29%5Cs-%3E%5Cs%28.%7B1%2C2%7D%29%2F'
         92        SEND_VAR                                                 !0
         93        SEND_REF                                                 !11
         94        DO_ICALL                                         $58     
         95        ASSIGN                                                   !12, $58
   37    96        COUNT                                            ~60     !11
         97        IS_SMALLER                                               0, ~60
         98      > JMPZ                                                     ~61, ->105
   38    99    >   INIT_ARRAY                                       ~62     6
        100        FETCH_DIM_R                                      ~63     !11, 1
        101        ADD_ARRAY_ELEMENT                                ~62     ~63
        102        FETCH_DIM_R                                      ~64     !11, 2
        103        ADD_ARRAY_ELEMENT                                ~62     ~64
        104      > RETURN                                                   ~62
   40   105    > > RETURN                                                   null

End of function operation

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.56 ms | 1415 KiB | 20 Q