3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = '1, 4, 7, 20-25, 31, 46-48, 100'; $array = array_map('trim', explode(',', $string)); $array_aux = array(); for ($i = 0; $i < count($array); $i++) { if (!is_numeric($array[$i])) { $new_array = explode('-', $array[$i]); for ($j = explode('-', $array[$i])[0]; $j <= $new_array[1]; $j++) array_splice($array_aux, 0, 0, $j); unset($array[$i]); } } $array = array_merge($array, $array_aux); sort($array); print_r($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
2 jumps found. (Code = 44) Position 1 = 48, Position 2 = 13
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 44
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 33
Branch analysis from position: 43
2 jumps found. (Code = 44) Position 1 = 48, Position 2 = 13
Branch analysis from position: 48
Branch analysis from position: 13
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 33
Branch analysis from position: 43
Branch analysis from position: 33
Branch analysis from position: 44
filename:       /in/iFFJ2
function name:  (null)
number of ops:  60
compiled vars:  !0 = $string, !1 = $array, !2 = $array_aux, !3 = $i, !4 = $new_array, !5 = $j
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '1%2C+4%2C+7%2C+20-25%2C+31%2C+46-48%2C+100'
    3     1        INIT_FCALL                                               'array_map'
          2        SEND_VAL                                                 'trim'
          3        INIT_FCALL                                               'explode'
          4        SEND_VAL                                                 '%2C'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $7      
          7        SEND_VAR                                                 $7
          8        DO_ICALL                                         $8      
          9        ASSIGN                                                   !1, $8
    4    10        ASSIGN                                                   !2, <array>
    6    11        ASSIGN                                                   !3, 0
         12      > JMP                                                      ->45
    7    13    >   INIT_FCALL                                               'is_numeric'
         14        FETCH_DIM_R                                      ~12     !1, !3
         15        SEND_VAL                                                 ~12
         16        DO_ICALL                                         $13     
         17        BOOL_NOT                                         ~14     $13
         18      > JMPZ                                                     ~14, ->44
    8    19    >   INIT_FCALL                                               'explode'
         20        SEND_VAL                                                 '-'
         21        FETCH_DIM_R                                      ~15     !1, !3
         22        SEND_VAL                                                 ~15
         23        DO_ICALL                                         $16     
         24        ASSIGN                                                   !4, $16
   10    25        INIT_FCALL                                               'explode'
         26        SEND_VAL                                                 '-'
         27        FETCH_DIM_R                                      ~18     !1, !3
         28        SEND_VAL                                                 ~18
         29        DO_ICALL                                         $19     
         30        FETCH_DIM_R                                      ~20     $19, 0
         31        ASSIGN                                                   !5, ~20
         32      > JMP                                                      ->40
   11    33    >   INIT_FCALL                                               'array_splice'
         34        SEND_REF                                                 !2
         35        SEND_VAL                                                 0
         36        SEND_VAL                                                 0
         37        SEND_VAR                                                 !5
         38        DO_ICALL                                                 
   10    39        PRE_INC                                                  !5
         40    >   FETCH_DIM_R                                      ~24     !4, 1
         41        IS_SMALLER_OR_EQUAL                                      !5, ~24
         42      > JMPNZ                                                    ~25, ->33
   13    43    >   UNSET_DIM                                                !1, !3
    6    44    >   PRE_INC                                                  !3
         45    >   COUNT                                            ~27     !1
         46        IS_SMALLER                                               !3, ~27
         47      > JMPNZ                                                    ~28, ->13
   17    48    >   INIT_FCALL                                               'array_merge'
         49        SEND_VAR                                                 !1
         50        SEND_VAR                                                 !2
         51        DO_ICALL                                         $29     
         52        ASSIGN                                                   !1, $29
   19    53        INIT_FCALL                                               'sort'
         54        SEND_REF                                                 !1
         55        DO_ICALL                                                 
   20    56        INIT_FCALL                                               'print_r'
         57        SEND_VAR                                                 !1
         58        DO_ICALL                                                 
         59      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.33 ms | 1400 KiB | 27 Q