3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = '1, 4, 7, 20-25, 31, 46, 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 = $new_array[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 = 40
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 13
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 39
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 28
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 13
Branch analysis from position: 43
Branch analysis from position: 13
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 28
Branch analysis from position: 38
Branch analysis from position: 28
Branch analysis from position: 39
filename:       /in/sk40Y
function name:  (null)
number of ops:  55
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%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>
    5    11        ASSIGN                                                   !3, 0
         12      > JMP                                                      ->40
    6    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, ->39
    7    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
    9    25        FETCH_DIM_R                                      ~18     !4, 0
         26        ASSIGN                                                   !5, ~18
         27      > JMP                                                      ->35
   10    28    >   INIT_FCALL                                               'array_splice'
         29        SEND_REF                                                 !2
         30        SEND_VAL                                                 0
         31        SEND_VAL                                                 0
         32        SEND_VAR                                                 !5
         33        DO_ICALL                                                 
    9    34        PRE_INC                                                  !5
         35    >   FETCH_DIM_R                                      ~22     !4, 1
         36        IS_SMALLER_OR_EQUAL                                      !5, ~22
         37      > JMPNZ                                                    ~23, ->28
   13    38    >   UNSET_DIM                                                !1, !3
    5    39    >   PRE_INC                                                  !3
         40    >   COUNT                                            ~25     !1
         41        IS_SMALLER                                               !3, ~25
         42      > JMPNZ                                                    ~26, ->13
   16    43    >   INIT_FCALL                                               'array_merge'
         44        SEND_VAR                                                 !1
         45        SEND_VAR                                                 !2
         46        DO_ICALL                                         $27     
         47        ASSIGN                                                   !1, $27
   18    48        INIT_FCALL                                               'sort'
         49        SEND_REF                                                 !1
         50        DO_ICALL                                                 
   20    51        INIT_FCALL                                               'print_r'
         52        SEND_VAR                                                 !1
         53        DO_ICALL                                                 
         54      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.45 ms | 1392 KiB | 27 Q