3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = '3-6,8,12,14-50'; $result = []; foreach (explode(',', $string) as $v) { $x = explode('-', $v); array_push($result, ...range($x[0], $x[1] ?? $v)); } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 27
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 27
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/e7GOm
function name:  (null)
number of ops:  32
compiled vars:  !0 = $string, !1 = $result, !2 = $v, !3 = $x
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                                         $6      
          6      > FE_RESET_R                                       $7      $6, ->27
          7    > > FE_FETCH_R                                               $7, !2, ->27
    7     8    >   INIT_FCALL                                               'explode'
          9        SEND_VAL                                                 '-'
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                         $8      
         12        ASSIGN                                                   !3, $8
    8    13        INIT_FCALL                                               'array_push'
         14        SEND_REF                                                 !1
         15        INIT_FCALL                                               'range'
         16        FETCH_DIM_R                                      ~10     !3, 0
         17        SEND_VAL                                                 ~10
         18        FETCH_DIM_IS                                     ~11     !3, 1
         19        COALESCE                                         ~12     ~11
         20        QM_ASSIGN                                        ~12     !2
         21        SEND_VAL                                                 ~12
         22        DO_ICALL                                         $13     
         23        SEND_UNPACK                                              $13
         24        CHECK_UNDEF_ARGS                                         
         25        DO_ICALL                                                 
    6    26      > JMP                                                      ->7
         27    >   FE_FREE                                                  $7
   10    28        INIT_FCALL                                               'var_export'
         29        SEND_VAR                                                 !1
         30        DO_ICALL                                                 
         31      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
239.24 ms | 1009 KiB | 17 Q