3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = '3-6,8,12,14-50'; $result = []; foreach (explode(',', $string) as $v) { if (sscanf($v, '%d-%d', $start, $end) === 1) { $result[] = $start; } else { array_push($result, ...range($start, $end)); } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 29
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 29
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 19
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/cvgO2
function name:  (null)
number of ops:  34
compiled vars:  !0 = $string, !1 = $result, !2 = $v, !3 = $start, !4 = $end
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '3-6%2C8%2C12%2C14-50'
    5     1        ASSIGN                                                   !1, <array>
    6     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '%2C'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $7      
          6      > FE_RESET_R                                       $8      $7, ->29
          7    > > FE_FETCH_R                                               $8, !2, ->29
    7     8    >   INIT_FCALL                                               'sscanf'
          9        SEND_VAR                                                 !2
         10        SEND_VAL                                                 '%25d-%25d'
         11        SEND_REF                                                 !3
         12        SEND_REF                                                 !4
         13        DO_ICALL                                         $9      
         14        IS_IDENTICAL                                             $9, 1
         15      > JMPZ                                                     ~10, ->19
    8    16    >   ASSIGN_DIM                                               !1
         17        OP_DATA                                                  !3
    7    18      > JMP                                                      ->28
   10    19    >   INIT_FCALL                                               'array_push'
         20        SEND_REF                                                 !1
         21        INIT_FCALL                                               'range'
         22        SEND_VAR                                                 !3
         23        SEND_VAR                                                 !4
         24        DO_ICALL                                         $12     
         25        SEND_UNPACK                                              $12
         26        CHECK_UNDEF_ARGS                                         
         27        DO_ICALL                                                 
    6    28    > > JMP                                                      ->7
         29    >   FE_FREE                                                  $8
   13    30        INIT_FCALL                                               'var_export'
         31        SEND_VAR                                                 !1
         32        DO_ICALL                                                 
         33      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.93 ms | 1010 KiB | 18 Q