3v4l.org

run code in 500+ PHP versions simultaneously
<?php $result = "How much is 25.5 + 35.5"; $allowed = array('1','2','3','4','5','6','7', '8', '9','0','-','+','/','*','.'); $regex = sprintf('/([%s]+)/u', preg_quote(join($allowed), '/')); preg_match_all($regex, $result, $match); switch($match[0][1]){ case '-': echo $match[0][0] - $match[0][2]; break; case '*': echo $match[0][0] * $match[0][2]; break; case '+': echo $match[0][0] + $match[0][2]; break; case '/': echo $match[0][0] / $match[0][2]; break; }
Finding entry points
Branch analysis from position: 0
6 jumps found. (Code = 188) Position 1 = 30, Position 2 = 37, Position 3 = 44, Position 4 = 51, Position 5 = 58, Position 6 = 21
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
Branch analysis from position: 51
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
Branch analysis from position: 58
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 30
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 37
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 44
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 51
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
Branch analysis from position: 51
Branch analysis from position: 44
Branch analysis from position: 37
Branch analysis from position: 30
filename:       /in/Ug20p
function name:  (null)
number of ops:  60
compiled vars:  !0 = $result, !1 = $allowed, !2 = $regex, !3 = $match
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, 'How+much+is+25.5+%2B+35.5'
    3     1        ASSIGN                                                       !1, <array>
    4     2        INIT_FCALL                                                   'preg_quote'
          3        INIT_FCALL                                                   'join'
          4        SEND_VAR                                                     !1
          5        DO_ICALL                                             $6      
          6        SEND_VAR                                                     $6
          7        SEND_VAL                                                     '%2F'
          8        DO_ICALL                                             $7      
          9        ROPE_INIT                                         3  ~9      '%2F%28%5B'
         10        ROPE_ADD                                          1  ~9      ~9, $7
         11        ROPE_END                                          2  ~8      ~9, '%5D%2B%29%2Fu'
         12        ASSIGN                                                       !2, ~8
    5    13        INIT_FCALL                                                   'preg_match_all'
         14        SEND_VAR                                                     !2
         15        SEND_VAR                                                     !0
         16        SEND_REF                                                     !3
         17        DO_ICALL                                                     
    6    18        FETCH_DIM_R                                          ~13     !3, 0
         19        FETCH_DIM_R                                          ~14     ~13, 1
         20      > SWITCH_STRING                                                ~14, [ '-':->30, '%2A':->37, '%2B':->44, '%2F':->51, ], ->58
    7    21    >   CASE                                                         ~14, '-'
         22      > JMPNZ                                                        ~15, ->30
   10    23    >   CASE                                                         ~14, '%2A'
         24      > JMPNZ                                                        ~15, ->37
   13    25    >   CASE                                                         ~14, '%2B'
         26      > JMPNZ                                                        ~15, ->44
   16    27    >   CASE                                                         ~14, '%2F'
         28      > JMPNZ                                                        ~15, ->51
         29    > > JMP                                                          ->58
    8    30    >   FETCH_DIM_R                                          ~16     !3, 0
         31        FETCH_DIM_R                                          ~17     ~16, 0
         32        FETCH_DIM_R                                          ~18     !3, 0
         33        FETCH_DIM_R                                          ~19     ~18, 2
         34        SUB                                                  ~20     ~17, ~19
         35        ECHO                                                         ~20
    9    36      > JMP                                                          ->58
   11    37    >   FETCH_DIM_R                                          ~21     !3, 0
         38        FETCH_DIM_R                                          ~22     ~21, 0
         39        FETCH_DIM_R                                          ~23     !3, 0
         40        FETCH_DIM_R                                          ~24     ~23, 2
         41        MUL                                                  ~25     ~22, ~24
         42        ECHO                                                         ~25
   12    43      > JMP                                                          ->58
   14    44    >   FETCH_DIM_R                                          ~26     !3, 0
         45        FETCH_DIM_R                                          ~27     ~26, 0
         46        FETCH_DIM_R                                          ~28     !3, 0
         47        FETCH_DIM_R                                          ~29     ~28, 2
         48        ADD                                                  ~30     ~27, ~29
         49        ECHO                                                         ~30
   15    50      > JMP                                                          ->58
   17    51    >   FETCH_DIM_R                                          ~31     !3, 0
         52        FETCH_DIM_R                                          ~32     ~31, 0
         53        FETCH_DIM_R                                          ~33     !3, 0
         54        FETCH_DIM_R                                          ~34     ~33, 2
         55        DIV                                                  ~35     ~32, ~34
         56        ECHO                                                         ~35
   18    57      > JMP                                                          ->58
         58    >   FREE                                                         ~14
   19    59      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
166.64 ms | 1857 KiB | 18 Q