3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "description: test1: 10 €, test2: 7.50 €, test3: 25%, test4: 30%"; $levelamt = 0.75; $description = preg_replace_callback('/(\d+(?:\.\d+)?)(\s*[€%])/i', function($matches) use ($levelamt){ return number_format(round(($matches[1] * $levelamt), 2), 2).$matches[2]; }, $string); echo $description;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kIrUH
function name:  (null)
number of ops:  12
compiled vars:  !0 = $string, !1 = $levelamt, !2 = $description
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'description%3A+test1%3A+10+%E2%82%AC%2C+test2%3A+7.50+%E2%82%AC%2C+test3%3A+25%25%2C+test4%3A+30%25'
    4     1        ASSIGN                                                   !1, 0.75
    6     2        INIT_FCALL                                               'preg_replace_callback'
          3        SEND_VAL                                                 '%2F%28%5Cd%2B%28%3F%3A%5C.%5Cd%2B%29%3F%29%28%5Cs%2A%5B%E2%82%AC%25%5D%29%2Fi'
          4        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
          5        BIND_LEXICAL                                             ~5, !1
    8     6        SEND_VAL                                                 ~5
          7        SEND_VAR                                                 !0
    6     8        DO_ICALL                                         $6      
          9        ASSIGN                                                   !2, $6
   10    10        ECHO                                                     !2
   11    11      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kIrUH
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $matches, !1 = $levelamt
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
    7     2        INIT_FCALL                                               'number_format'
          3        INIT_FCALL                                               'round'
          4        FETCH_DIM_R                                      ~2      !0, 1
          5        MUL                                              ~3      !1, ~2
          6        SEND_VAL                                                 ~3
          7        SEND_VAL                                                 2
          8        DO_ICALL                                         $4      
          9        SEND_VAR                                                 $4
         10        SEND_VAL                                                 2
         11        DO_ICALL                                         $5      
         12        FETCH_DIM_R                                      ~6      !0, 2
         13        CONCAT                                           ~7      $5, ~6
         14      > RETURN                                                   ~7
    8    15*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.93 ms | 1013 KiB | 16 Q