3v4l.org

run code in 300+ PHP versions simultaneously
<?php function parse_range_str($str_input) { $arr_result = []; foreach (preg_split('/\s*,\s*/', $str_input) as $str_range) { $arr_range = preg_split('/\s*-\s*/', $str_range); if (isset($arr_range[1])) { $arr_result = array_merge($arr_result, range((int) $arr_range[0], (int) $arr_range[1])); } else { $arr_result[] = (int) $arr_range[0]; } } return $arr_result; } var_dump(parse_range_str('1,2,8-12,16'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LCMWl
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'parse_range_str'
          2        SEND_VAL                                                 '1%2C2%2C8-12%2C16'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
          6      > RETURN                                                   1

Function parse_range_str:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 34
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 34
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 29
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
filename:       /in/LCMWl
function name:  parse_range_str
number of ops:  37
compiled vars:  !0 = $str_input, !1 = $arr_result, !2 = $str_range, !3 = $arr_range
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, <array>
    7     2        INIT_FCALL                                               'preg_split'
          3        SEND_VAL                                                 '%2F%5Cs%2A%2C%5Cs%2A%2F'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $5      
          6      > FE_RESET_R                                       $6      $5, ->34
          7    > > FE_FETCH_R                                               $6, !2, ->34
    8     8    >   INIT_FCALL                                               'preg_split'
          9        SEND_VAL                                                 '%2F%5Cs%2A-%5Cs%2A%2F'
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                         $7      
         12        ASSIGN                                                   !3, $7
   10    13        ISSET_ISEMPTY_DIM_OBJ                         0          !3, 1
         14      > JMPZ                                                     ~9, ->29
   11    15    >   INIT_FCALL                                               'array_merge'
         16        SEND_VAR                                                 !1
         17        INIT_FCALL                                               'range'
         18        FETCH_DIM_R                                      ~10     !3, 0
         19        CAST                                          4  ~11     ~10
         20        SEND_VAL                                                 ~11
         21        FETCH_DIM_R                                      ~12     !3, 1
         22        CAST                                          4  ~13     ~12
         23        SEND_VAL                                                 ~13
         24        DO_ICALL                                         $14     
         25        SEND_VAR                                                 $14
         26        DO_ICALL                                         $15     
         27        ASSIGN                                                   !1, $15
         28      > JMP                                                      ->33
   13    29    >   FETCH_DIM_R                                      ~18     !3, 0
         30        CAST                                          4  ~19     ~18
         31        ASSIGN_DIM                                               !1
         32        OP_DATA                                                  ~19
    7    33    > > JMP                                                      ->7
         34    >   FE_FREE                                                  $6
   17    35      > RETURN                                                   !1
   18    36*     > RETURN                                                   null

End of function parse_range_str

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.65 ms | 1403 KiB | 22 Q