3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = '(2 * 10 + 5) Euro and (10 + 2) cents'; $regex = '#\((([^()]+|(?R))*)\)#'; if (preg_match_all($regex, $string ,$matches)) { $eqs = $matches[1]; foreach($eqs as $frm) { $frm_eval = eval("return $frm;"); $string = str_replace('(' . $frm . ')', $frm_eval, $string); } echo $string; } else { //no parenthesis echo $string; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 29
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 26
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 26
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/m1IYJ
function name:  (null)
number of ops:  31
compiled vars:  !0 = $string, !1 = $regex, !2 = $matches, !3 = $eqs, !4 = $frm, !5 = $frm_eval
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%282+%2A+10+%2B+5%29+Euro+and+%2810+%2B+2%29+cents'
    3     1        ASSIGN                                                   !1, '%23%5C%28%28%28%5B%5E%28%29%5D%2B%7C%28%3FR%29%29%2A%29%5C%29%23'
    4     2        INIT_FCALL                                               'preg_match_all'
          3        SEND_VAR                                                 !1
          4        SEND_VAR                                                 !0
          5        SEND_REF                                                 !2
          6        DO_ICALL                                         $8      
          7      > JMPZ                                                     $8, ->29
    5     8    >   FETCH_DIM_R                                      ~9      !2, 1
          9        ASSIGN                                                   !3, ~9
    6    10      > FE_RESET_R                                       $11     !3, ->26
         11    > > FE_FETCH_R                                               $11, !4, ->26
    7    12    >   ROPE_INIT                                     3  ~13     'return+'
         13        ROPE_ADD                                      1  ~13     ~13, !4
         14        ROPE_END                                      2  ~12     ~13, '%3B'
         15        INCLUDE_OR_EVAL                                  $15     ~12, EVAL
         16        ASSIGN                                                   !5, $15
    8    17        INIT_FCALL                                               'str_replace'
         18        CONCAT                                           ~17     '%28', !4
         19        CONCAT                                           ~18     ~17, '%29'
         20        SEND_VAL                                                 ~18
         21        SEND_VAR                                                 !5
         22        SEND_VAR                                                 !0
         23        DO_ICALL                                         $19     
         24        ASSIGN                                                   !0, $19
    6    25      > JMP                                                      ->11
         26    >   FE_FREE                                                  $11
   11    27        ECHO                                                     !0
         28      > JMP                                                      ->30
   15    29    >   ECHO                                                     !0
   16    30    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.02 ms | 1396 KiB | 17 Q