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)); $new_array = array(); for ($i = 0; $i < count($array); $i++) { if (!is_numeric($array[$i])) { for ($j = explode('-', $array[$i])[0]; $j <= explode('-', $array[$i])[1]; $j++) array_splice($new_array, 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 = 44
Branch analysis from position: 44
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 13
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 43
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 27
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 13
Branch analysis from position: 47
Branch analysis from position: 13
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 27
Branch analysis from position: 42
Branch analysis from position: 27
Branch analysis from position: 43
filename:       /in/Bgcj7
function name:  (null)
number of ops:  59
compiled vars:  !0 = $string, !1 = $array, !2 = $new_array, !3 = $i, !4 = $j, !5 = $array_aux
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                                                      ->44
    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, ->43
    9    19    >   INIT_FCALL                                               'explode'
         20        SEND_VAL                                                 '-'
         21        FETCH_DIM_R                                      ~15     !1, !3
         22        SEND_VAL                                                 ~15
         23        DO_ICALL                                         $16     
         24        FETCH_DIM_R                                      ~17     $16, 0
         25        ASSIGN                                                   !4, ~17
         26      > JMP                                                      ->34
   10    27    >   INIT_FCALL                                               'array_splice'
         28        SEND_REF                                                 !2
         29        SEND_VAL                                                 0
         30        SEND_VAL                                                 0
         31        SEND_VAR                                                 !4
         32        DO_ICALL                                                 
    9    33        PRE_INC                                                  !4
         34    >   INIT_FCALL                                               'explode'
         35        SEND_VAL                                                 '-'
         36        FETCH_DIM_R                                      ~21     !1, !3
         37        SEND_VAL                                                 ~21
         38        DO_ICALL                                         $22     
         39        FETCH_DIM_R                                      ~23     $22, 1
         40        IS_SMALLER_OR_EQUAL                                      !4, ~23
         41      > JMPNZ                                                    ~24, ->27
   12    42    >   UNSET_DIM                                                !1, !3
    6    43    >   PRE_INC                                                  !3
         44    >   COUNT                                            ~26     !1
         45        IS_SMALLER                                               !3, ~26
         46      > JMPNZ                                                    ~27, ->13
   16    47    >   INIT_FCALL                                               'array_merge'
         48        SEND_VAR                                                 !1
         49        SEND_VAR                                                 !5
         50        DO_ICALL                                         $28     
         51        ASSIGN                                                   !1, $28
   18    52        INIT_FCALL                                               'sort'
         53        SEND_REF                                                 !1
         54        DO_ICALL                                                 
   19    55        INIT_FCALL                                               'print_r'
         56        SEND_VAR                                                 !1
         57        DO_ICALL                                                 
         58      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.27 ms | 1400 KiB | 27 Q