3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = '$1.1m Foo £2,2b Bar €99.9'; $lookup = [ 'b' => 'million platinum coins', 'm' => 'million gold coins', '' => 'gold coins', ]; echo preg_replace_callback( '~[$£€](\d+(?:[.,]\d+)?)([bm]?)~iu', function($m) use ($lookup) { return "$m[1] " . $lookup[strtolower($m[2])]; }, $str );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/X7mYb
function name:  (null)
number of ops:  11
compiled vars:  !0 = $str, !1 = $lookup
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%241.1m%0AFoo%0A%C2%A32%2C2b%0ABar%0A%E2%82%AC99.9'
    9     1        ASSIGN                                                   !1, <array>
   15     2        INIT_FCALL                                               'preg_replace_callback'
   16     3        SEND_VAL                                                 '%7E%5B%24%C2%A3%E2%82%AC%5D%28%5Cd%2B%28%3F%3A%5B.%2C%5D%5Cd%2B%29%3F%29%28%5Bbm%5D%3F%29%7Eiu'
   17     4        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
          5        BIND_LEXICAL                                             ~4, !1
   19     6        SEND_VAL                                                 ~4
   20     7        SEND_VAR                                                 !0
   15     8        DO_ICALL                                         $5      
   20     9        ECHO                                                     $5
   21    10      > 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/X7mYb
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $m, !1 = $lookup
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   18     2        FETCH_DIM_R                                      ~2      !0, 1
          3        NOP                                                      
          4        FAST_CONCAT                                      ~3      ~2, '+'
          5        INIT_FCALL                                               'strtolower'
          6        FETCH_DIM_R                                      ~4      !0, 2
          7        SEND_VAL                                                 ~4
          8        DO_ICALL                                         $5      
          9        FETCH_DIM_R                                      ~6      !1, $5
         10        CONCAT                                           ~7      ~3, ~6
         11      > RETURN                                                   ~7
   19    12*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.81 ms | 1068 KiB | 15 Q