3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = 'A1-3, 5B-7'; echo preg_replace_callback_array( [ '/(\d+)([A-Z]+)-(\d+)/' => fn($m) => implode($m[2] . ', ', range($m[1], $m[3])) . $m[2], '/([A-Z]+)(\d+)-(\d+)/' => fn($m) => $m[1] . implode(', ' . $m[1], range($m[2], $m[3])), ], $string );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8eFKR
function name:  (null)
number of ops:  11
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'A1-3%2C+5B-7'
    5     1        INIT_FCALL                                               'preg_replace_callback_array'
    7     2        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
          3        INIT_ARRAY                                       ~3      ~2, '%2F%28%5Cd%2B%29%28%5BA-Z%5D%2B%29-%28%5Cd%2B%29%2F'
    8     4        DECLARE_LAMBDA_FUNCTION                          ~4      [1]
          5        ADD_ARRAY_ELEMENT                                ~3      ~4, '%2F%28%5BA-Z%5D%2B%29%28%5Cd%2B%29-%28%5Cd%2B%29%2F'
          6        SEND_VAL                                                 ~3
   10     7        SEND_VAR                                                 !0
    5     8        DO_ICALL                                         $5      
   10     9        ECHO                                                     $5
   11    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/8eFKR
function name:  {closure}
number of ops:  17
compiled vars:  !0 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'implode'
          2        FETCH_DIM_R                                      ~1      !0, 2
          3        CONCAT                                           ~2      ~1, '%2C+'
          4        SEND_VAL                                                 ~2
          5        INIT_FCALL                                               'range'
          6        FETCH_DIM_R                                      ~3      !0, 1
          7        SEND_VAL                                                 ~3
          8        FETCH_DIM_R                                      ~4      !0, 3
          9        SEND_VAL                                                 ~4
         10        DO_ICALL                                         $5      
         11        SEND_VAR                                                 $5
         12        DO_ICALL                                         $6      
         13        FETCH_DIM_R                                      ~7      !0, 2
         14        CONCAT                                           ~8      $6, ~7
         15      > RETURN                                                   ~8
         16*     > RETURN                                                   null

End of Dynamic Function 0

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

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.04 ms | 1017 KiB | 16 Q