3v4l.org

run code in 300+ PHP versions simultaneously
<?php $mobile = '123456789'; $pattern = '(xx)-xxxxxxx'; echo preg_replace_callback('/x+/', function ($match) use (&$mobile) { $length = strlen($match[0]); $replacement = substr($mobile, 0, $length); $mobile = substr($mobile, $length); return $replacement; }, $pattern);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9QCD6
function name:  (null)
number of ops:  11
compiled vars:  !0 = $mobile, !1 = $pattern
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '123456789'
    4     1        ASSIGN                                                   !1, '%28xx%29-xxxxxxx'
    6     2        INIT_FCALL                                               'preg_replace_callback'
          3        SEND_VAL                                                 '%2Fx%2B%2F'
          4        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
          5        BIND_LEXICAL                                             ~4, !0
   14     6        SEND_VAL                                                 ~4
          7        SEND_VAR                                                 !1
    6     8        DO_ICALL                                         $5      
   14     9        ECHO                                                     $5
         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/9QCD6
function name:  {closure}
number of ops:  18
compiled vars:  !0 = $match, !1 = $mobile, !2 = $length, !3 = $replacement
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
    7     2        FETCH_DIM_R                                      ~4      !0, 0
          3        STRLEN                                           ~5      ~4
          4        ASSIGN                                                   !2, ~5
    9     5        INIT_FCALL                                               'substr'
          6        SEND_VAR                                                 !1
          7        SEND_VAL                                                 0
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                         $7      
         10        ASSIGN                                                   !3, $7
   11    11        INIT_FCALL                                               'substr'
         12        SEND_VAR                                                 !1
         13        SEND_VAR                                                 !2
         14        DO_ICALL                                         $9      
         15        ASSIGN                                                   !1, $9
   13    16      > RETURN                                                   !3
   14    17*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.19 ms | 1083 KiB | 15 Q