3v4l.org

run code in 500+ 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:/in/8eFKR:7}
number of ops:  14
compiled vars:  !0 = $m
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   RECV                                                 !0      
          1        FETCH_DIM_R                                          ~1      !0, 2
          2        CONCAT                                               ~2      ~1, '%2C+'
          3        INIT_FCALL                                                   'range'
          4        FETCH_DIM_R                                          ~3      !0, 1
          5        SEND_VAL                                                     ~3
          6        FETCH_DIM_R                                          ~4      !0, 3
          7        SEND_VAL                                                     ~4
          8        DO_ICALL                                             $5      
          9        FRAMELESS_ICALL_2                implode             ~6      ~2, $5
         10        FETCH_DIM_R                                          ~7      !0, 2
         11        CONCAT                                               ~8      ~6, ~7
         12      > RETURN                                                       ~8
         13*     > 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:/in/8eFKR:8}
number of ops:  14
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        FETCH_DIM_R                                          ~2      !0, 1
          3        CONCAT                                               ~3      '%2C+', ~2
          4        INIT_FCALL                                                   'range'
          5        FETCH_DIM_R                                          ~4      !0, 2
          6        SEND_VAL                                                     ~4
          7        FETCH_DIM_R                                          ~5      !0, 3
          8        SEND_VAL                                                     ~5
          9        DO_ICALL                                             $6      
         10        FRAMELESS_ICALL_2                implode             ~7      ~3, $6
         11        CONCAT                                               ~8      ~1, ~7
         12      > RETURN                                                       ~8
         13*     > RETURN                                                       null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
167.15 ms | 1716 KiB | 15 Q