3v4l.org

run code in 300+ PHP versions simultaneously
<?php $equation = '1-1'; $stored = $equation; $components = preg_split('~([*/%+-])~', $stored, NULL, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); while (($index = array_search('*', $components)) !== false) { array_splice($components, $index - 1, 3, $components[$index - 1] * $components[$index + 1]); } while (($index = array_search('/', $components)) !== false) { array_splice($components, $index - 1, 3, $components[$index - 1] / $components[$index + 1]); } while (($index = array_search('%', $components)) !== false) { array_splice($components, $index - 1, 3, fmod($components[$index - 1], $components[$index + 1])); } while (($index = array_search('+', $components)) !== false) { array_splice($components, $index - 1, 3, $components[$index - 1] + $components[$index + 1]); } $count = 0; var_dump($components); while (($index = array_search('-', $components)) !== false) { echo "First\n"; var_dump($components); array_splice($components, $index - 1, 3, $components[$index - 1] - $components[$index + 1]); echo "Second\n"; var_dump($components); $count++; if($count > 3) die('Too many'); } echo current($components);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 10
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 30
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 65
Branch analysis from position: 65
2 jumps found. (Code = 44) Position 1 = 72, Position 2 = 50
Branch analysis from position: 72
1 jumps found. (Code = 42) Position 1 = 85
Branch analysis from position: 85
2 jumps found. (Code = 44) Position 1 = 92, Position 2 = 73
Branch analysis from position: 92
1 jumps found. (Code = 42) Position 1 = 121
Branch analysis from position: 121
2 jumps found. (Code = 44) Position 1 = 128, Position 2 = 97
Branch analysis from position: 128
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 97
2 jumps found. (Code = 43) Position 1 = 120, Position 2 = 121
Branch analysis from position: 120
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 121
Branch analysis from position: 73
2 jumps found. (Code = 44) Position 1 = 92, Position 2 = 73
Branch analysis from position: 92
Branch analysis from position: 73
Branch analysis from position: 50
2 jumps found. (Code = 44) Position 1 = 72, Position 2 = 50
Branch analysis from position: 72
Branch analysis from position: 50
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 30
Branch analysis from position: 49
Branch analysis from position: 30
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 10
Branch analysis from position: 29
Branch analysis from position: 10
filename:       /in/IhW94
function name:  (null)
number of ops:  133
compiled vars:  !0 = $equation, !1 = $stored, !2 = $components, !3 = $index, !4 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '1-1'
    5     1        ASSIGN                                                   !1, !0
    6     2        INIT_FCALL                                               'preg_split'
          3        SEND_VAL                                                 '%7E%28%5B%2A%2F%25%2B-%5D%29%7E'
          4        SEND_VAR                                                 !1
          5        SEND_VAL                                                 null
          6        SEND_VAL                                                 3
          7        DO_ICALL                                         $7      
          8        ASSIGN                                                   !2, $7
    8     9      > JMP                                                      ->22
    9    10    >   INIT_FCALL                                               'array_splice'
         11        SEND_REF                                                 !2
         12        SUB                                              ~9      !3, 1
         13        SEND_VAL                                                 ~9
         14        SEND_VAL                                                 3
         15        SUB                                              ~10     !3, 1
         16        FETCH_DIM_R                                      ~11     !2, ~10
         17        ADD                                              ~12     !3, 1
         18        FETCH_DIM_R                                      ~13     !2, ~12
         19        MUL                                              ~14     ~11, ~13
         20        SEND_VAL                                                 ~14
         21        DO_ICALL                                                 
    8    22    >   INIT_FCALL                                               'array_search'
         23        SEND_VAL                                                 '%2A'
         24        SEND_VAR                                                 !2
         25        DO_ICALL                                         $16     
         26        ASSIGN                                           ~17     !3, $16
         27        TYPE_CHECK                                  1018          ~17
         28      > JMPNZ                                                    ~18, ->10
   11    29    > > JMP                                                      ->42
   12    30    >   INIT_FCALL                                               'array_splice'
         31        SEND_REF                                                 !2
         32        SUB                                              ~19     !3, 1
         33        SEND_VAL                                                 ~19
         34        SEND_VAL                                                 3
         35        SUB                                              ~20     !3, 1
         36        FETCH_DIM_R                                      ~21     !2, ~20
         37        ADD                                              ~22     !3, 1
         38        FETCH_DIM_R                                      ~23     !2, ~22
         39        DIV                                              ~24     ~21, ~23
         40        SEND_VAL                                                 ~24
         41        DO_ICALL                                                 
   11    42    >   INIT_FCALL                                               'array_search'
         43        SEND_VAL                                                 '%2F'
         44        SEND_VAR                                                 !2
         45        DO_ICALL                                         $26     
         46        ASSIGN                                           ~27     !3, $26
         47        TYPE_CHECK                                  1018          ~27
         48      > JMPNZ                                                    ~28, ->30
   14    49    > > JMP                                                      ->65
   15    50    >   INIT_FCALL                                               'array_splice'
         51        SEND_REF                                                 !2
         52        SUB                                              ~29     !3, 1
         53        SEND_VAL                                                 ~29
         54        SEND_VAL                                                 3
         55        INIT_FCALL                                               'fmod'
         56        SUB                                              ~30     !3, 1
         57        FETCH_DIM_R                                      ~31     !2, ~30
         58        SEND_VAL                                                 ~31
         59        ADD                                              ~32     !3, 1
         60        FETCH_DIM_R                                      ~33     !2, ~32
         61        SEND_VAL                                                 ~33
         62        DO_ICALL                                         $34     
         63        SEND_VAR                                                 $34
         64        DO_ICALL                                                 
   14    65    >   INIT_FCALL                                               'array_search'
         66        SEND_VAL                                                 '%25'
         67        SEND_VAR                                                 !2
         68        DO_ICALL                                         $36     
         69        ASSIGN                                           ~37     !3, $36
         70        TYPE_CHECK                                  1018          ~37
         71      > JMPNZ                                                    ~38, ->50
   17    72    > > JMP                                                      ->85
   18    73    >   INIT_FCALL                                               'array_splice'
         74        SEND_REF                                                 !2
         75        SUB                                              ~39     !3, 1
         76        SEND_VAL                                                 ~39
         77        SEND_VAL                                                 3
         78        SUB                                              ~40     !3, 1
         79        FETCH_DIM_R                                      ~41     !2, ~40
         80        ADD                                              ~42     !3, 1
         81        FETCH_DIM_R                                      ~43     !2, ~42
         82        ADD                                              ~44     ~41, ~43
         83        SEND_VAL                                                 ~44
         84        DO_ICALL                                                 
   17    85    >   INIT_FCALL                                               'array_search'
         86        SEND_VAL                                                 '%2B'
         87        SEND_VAR                                                 !2
         88        DO_ICALL                                         $46     
         89        ASSIGN                                           ~47     !3, $46
         90        TYPE_CHECK                                  1018          ~47
         91      > JMPNZ                                                    ~48, ->73
   20    92    >   ASSIGN                                                   !4, 0
   21    93        INIT_FCALL                                               'var_dump'
         94        SEND_VAR                                                 !2
         95        DO_ICALL                                                 
   22    96      > JMP                                                      ->121
   23    97    >   ECHO                                                     'First%0A'
   24    98        INIT_FCALL                                               'var_dump'
         99        SEND_VAR                                                 !2
        100        DO_ICALL                                                 
   25   101        INIT_FCALL                                               'array_splice'
        102        SEND_REF                                                 !2
        103        SUB                                              ~52     !3, 1
        104        SEND_VAL                                                 ~52
        105        SEND_VAL                                                 3
        106        SUB                                              ~53     !3, 1
        107        FETCH_DIM_R                                      ~54     !2, ~53
        108        ADD                                              ~55     !3, 1
        109        FETCH_DIM_R                                      ~56     !2, ~55
        110        SUB                                              ~57     ~54, ~56
        111        SEND_VAL                                                 ~57
        112        DO_ICALL                                                 
   26   113        ECHO                                                     'Second%0A'
   27   114        INIT_FCALL                                               'var_dump'
        115        SEND_VAR                                                 !2
        116        DO_ICALL                                                 
   28   117        PRE_INC                                                  !4
   29   118        IS_SMALLER                                               3, !4
        119      > JMPZ                                                     ~61, ->121
        120    > > EXIT                                                     'Too+many'
   22   121    >   INIT_FCALL                                               'array_search'
        122        SEND_VAL                                                 '-'
        123        SEND_VAR                                                 !2
        124        DO_ICALL                                         $62     
        125        ASSIGN                                           ~63     !3, $62
        126        TYPE_CHECK                                  1018          ~63
        127      > JMPNZ                                                    ~64, ->97
   32   128    >   INIT_FCALL                                               'current'
        129        SEND_VAR                                                 !2
        130        DO_ICALL                                         $65     
        131        ECHO                                                     $65
        132      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.75 ms | 1029 KiB | 19 Q