3v4l.org

run code in 300+ PHP versions simultaneously
<?php function range_string_to_array($range_string) { $range_string = trim($range_string); $return_array = array(); $return = array(); $range_string = str_replace(',', '+', $range_string); $range_string = str_replace(' ', '+', $range_string); if (is_numeric($range_string)) { return array($range_string); } $split_array = explode('+', $range_string); foreach ($split_array as $split1) { if ($split1 === '') { continue; } if (strpos($split1, '-') > -1) { $split = explode('-', $split1); if ($split[0] === '' && $split[1] === '') { continue; } if (floor($split[1]) != $split[1]) { $return_array[] = $split[1]; $return_array[] = floor($split[1]) + 1; } $return_array[] = $split[0]; foreach (range(floor($split[0]) + 1, $split[1], 1) as $split2) { $return_array[] = $split2; } } else { $return_array[] = $split1; } } foreach ($return_array as $return_array_val) { if (is_numeric($return_array_val)) { $return[] = $return_array_val; } } $return = array_unique($return); sort($return); return $return; } print_r(range_string_to_array('155.5-155.6'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SLIv2
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   48     0  E >   INIT_FCALL                                               'print_r'
          1        INIT_FCALL                                               'range_string_to_array'
          2        SEND_VAL                                                 '155.5-155.6'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
          6      > RETURN                                                   1

Function range_string_to_array:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
2 jumps found. (Code = 77) Position 1 = 31, Position 2 = 95
Branch analysis from position: 31
2 jumps found. (Code = 78) Position 1 = 32, Position 2 = 95
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 35
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 92
Branch analysis from position: 41
2 jumps found. (Code = 46) Position 1 = 49, Position 2 = 52
Branch analysis from position: 49
2 jumps found. (Code = 43) Position 1 = 53, Position 2 = 54
Branch analysis from position: 53
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 54
2 jumps found. (Code = 43) Position 1 = 61, Position 2 = 71
Branch analysis from position: 61
2 jumps found. (Code = 77) Position 1 = 86, Position 2 = 90
Branch analysis from position: 86
2 jumps found. (Code = 78) Position 1 = 87, Position 2 = 90
Branch analysis from position: 87
1 jumps found. (Code = 42) Position 1 = 86
Branch analysis from position: 86
Branch analysis from position: 90
1 jumps found. (Code = 42) Position 1 = 94
Branch analysis from position: 94
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 90
Branch analysis from position: 71
Branch analysis from position: 52
Branch analysis from position: 92
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 95
2 jumps found. (Code = 77) Position 1 = 97, Position 2 = 105
Branch analysis from position: 97
2 jumps found. (Code = 78) Position 1 = 98, Position 2 = 105
Branch analysis from position: 98
2 jumps found. (Code = 43) Position 1 = 102, Position 2 = 104
Branch analysis from position: 102
1 jumps found. (Code = 42) Position 1 = 97
Branch analysis from position: 97
Branch analysis from position: 104
Branch analysis from position: 105
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 105
Branch analysis from position: 95
filename:       /in/SLIv2
function name:  range_string_to_array
number of ops:  115
compiled vars:  !0 = $range_string, !1 = $return_array, !2 = $return, !3 = $split_array, !4 = $split1, !5 = $split, !6 = $split2, !7 = $return_array_val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'trim'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $8      
          4        ASSIGN                                                   !0, $8
    6     5        ASSIGN                                                   !1, <array>
    7     6        ASSIGN                                                   !2, <array>
    8     7        INIT_FCALL                                               'str_replace'
          8        SEND_VAL                                                 '%2C'
          9        SEND_VAL                                                 '%2B'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $12     
         12        ASSIGN                                                   !0, $12
    9    13        INIT_FCALL                                               'str_replace'
         14        SEND_VAL                                                 '+'
         15        SEND_VAL                                                 '%2B'
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                         $14     
         18        ASSIGN                                                   !0, $14
   11    19        INIT_FCALL                                               'is_numeric'
         20        SEND_VAR                                                 !0
         21        DO_ICALL                                         $16     
         22      > JMPZ                                                     $16, ->25
   12    23    >   INIT_ARRAY                                       ~17     !0
         24      > RETURN                                                   ~17
   15    25    >   INIT_FCALL                                               'explode'
         26        SEND_VAL                                                 '%2B'
         27        SEND_VAR                                                 !0
         28        DO_ICALL                                         $18     
         29        ASSIGN                                                   !3, $18
   16    30      > FE_RESET_R                                       $20     !3, ->95
         31    > > FE_FETCH_R                                               $20, !4, ->95
   17    32    >   IS_IDENTICAL                                             !4, ''
         33      > JMPZ                                                     ~21, ->35
   18    34    > > JMP                                                      ->31
   20    35    >   INIT_FCALL                                               'strpos'
         36        SEND_VAR                                                 !4
         37        SEND_VAL                                                 '-'
         38        DO_ICALL                                         $22     
         39        IS_SMALLER                                               -1, $22
         40      > JMPZ                                                     ~23, ->92
   21    41    >   INIT_FCALL                                               'explode'
         42        SEND_VAL                                                 '-'
         43        SEND_VAR                                                 !4
         44        DO_ICALL                                         $24     
         45        ASSIGN                                                   !5, $24
   22    46        FETCH_DIM_R                                      ~26     !5, 0
         47        IS_IDENTICAL                                     ~27     ~26, ''
         48      > JMPZ_EX                                          ~27     ~27, ->52
         49    >   FETCH_DIM_R                                      ~28     !5, 1
         50        IS_IDENTICAL                                     ~29     ~28, ''
         51        BOOL                                             ~27     ~29
         52    > > JMPZ                                                     ~27, ->54
   23    53    > > JMP                                                      ->31
   25    54    >   INIT_FCALL                                               'floor'
         55        FETCH_DIM_R                                      ~30     !5, 1
         56        SEND_VAL                                                 ~30
         57        DO_ICALL                                         $31     
         58        FETCH_DIM_R                                      ~32     !5, 1
         59        IS_NOT_EQUAL                                             $31, ~32
         60      > JMPZ                                                     ~33, ->71
   26    61    >   FETCH_DIM_R                                      ~35     !5, 1
         62        ASSIGN_DIM                                               !1
         63        OP_DATA                                                  ~35
   27    64        INIT_FCALL                                               'floor'
         65        FETCH_DIM_R                                      ~37     !5, 1
         66        SEND_VAL                                                 ~37
         67        DO_ICALL                                         $38     
         68        ADD                                              ~39     $38, 1
         69        ASSIGN_DIM                                               !1
         70        OP_DATA                                                  ~39
   29    71    >   FETCH_DIM_R                                      ~41     !5, 0
         72        ASSIGN_DIM                                               !1
         73        OP_DATA                                                  ~41
   30    74        INIT_FCALL                                               'range'
         75        INIT_FCALL                                               'floor'
         76        FETCH_DIM_R                                      ~42     !5, 0
         77        SEND_VAL                                                 ~42
         78        DO_ICALL                                         $43     
         79        ADD                                              ~44     $43, 1
         80        SEND_VAL                                                 ~44
         81        FETCH_DIM_R                                      ~45     !5, 1
         82        SEND_VAL                                                 ~45
         83        SEND_VAL                                                 1
         84        DO_ICALL                                         $46     
         85      > FE_RESET_R                                       $47     $46, ->90
         86    > > FE_FETCH_R                                               $47, !6, ->90
   31    87    >   ASSIGN_DIM                                               !1
         88        OP_DATA                                                  !6
   30    89      > JMP                                                      ->86
         90    >   FE_FREE                                                  $47
         91      > JMP                                                      ->94
   34    92    >   ASSIGN_DIM                                               !1
         93        OP_DATA                                                  !4
   16    94    > > JMP                                                      ->31
         95    >   FE_FREE                                                  $20
   37    96      > FE_RESET_R                                       $50     !1, ->105
         97    > > FE_FETCH_R                                               $50, !7, ->105
   38    98    >   INIT_FCALL                                               'is_numeric'
         99        SEND_VAR                                                 !7
        100        DO_ICALL                                         $51     
        101      > JMPZ                                                     $51, ->104
   39   102    >   ASSIGN_DIM                                               !2
        103        OP_DATA                                                  !7
   37   104    > > JMP                                                      ->97
        105    >   FE_FREE                                                  $50
   42   106        INIT_FCALL                                               'array_unique'
        107        SEND_VAR                                                 !2
        108        DO_ICALL                                         $53     
        109        ASSIGN                                                   !2, $53
   43   110        INIT_FCALL                                               'sort'
        111        SEND_REF                                                 !2
        112        DO_ICALL                                                 
   45   113      > RETURN                                                   !2
   46   114*     > RETURN                                                   null

End of function range_string_to_array

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.49 ms | 1411 KiB | 34 Q