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

End of function range_string_to_array

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.14 ms | 1411 KiB | 34 Q