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; if (floor($split[0]) != $split[0]) { $return_array[] = $split[0]; $split[0] = floor($split[0]) + 1; } echo $step; 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/TesP5
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 = 115
Branch analysis from position: 31
2 jumps found. (Code = 78) Position 1 = 32, Position 2 = 115
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 = 112
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 = 63, Position 2 = 73
Branch analysis from position: 63
2 jumps found. (Code = 43) Position 1 = 81, Position 2 = 90
Branch analysis from position: 81
2 jumps found. (Code = 43) Position 1 = 94, Position 2 = 111
Branch analysis from position: 94
2 jumps found. (Code = 77) Position 1 = 106, Position 2 = 110
Branch analysis from position: 106
2 jumps found. (Code = 78) Position 1 = 107, Position 2 = 110
Branch analysis from position: 107
1 jumps found. (Code = 42) Position 1 = 106
Branch analysis from position: 106
Branch analysis from position: 110
1 jumps found. (Code = 42) Position 1 = 114
Branch analysis from position: 114
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 110
Branch analysis from position: 111
Branch analysis from position: 90
Branch analysis from position: 73
Branch analysis from position: 52
Branch analysis from position: 112
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 115
2 jumps found. (Code = 77) Position 1 = 117, Position 2 = 125
Branch analysis from position: 117
2 jumps found. (Code = 78) Position 1 = 118, Position 2 = 125
Branch analysis from position: 118
2 jumps found. (Code = 43) Position 1 = 122, Position 2 = 124
Branch analysis from position: 122
1 jumps found. (Code = 42) Position 1 = 117
Branch analysis from position: 117
Branch analysis from position: 124
Branch analysis from position: 125
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 125
Branch analysis from position: 115
filename:       /in/TesP5
function name:  range_string_to_array
number of ops:  135
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, ->115
         31    > > FE_FETCH_R                                               $21, !4, ->115
   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, ->112
   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        ECHO                                                     !6
   28    56        INIT_FCALL                                               'floor'
         57        FETCH_DIM_R                                      ~32     !5, 0
         58        SEND_VAL                                                 ~32
         59        DO_ICALL                                         $33     
         60        FETCH_DIM_R                                      ~34     !5, 0
         61        IS_NOT_EQUAL                                             $33, ~34
         62      > JMPZ                                                     ~35, ->73
   29    63    >   FETCH_DIM_R                                      ~37     !5, 0
         64        ASSIGN_DIM                                               !1
         65        OP_DATA                                                  ~37
   30    66        INIT_FCALL                                               'floor'
         67        FETCH_DIM_R                                      ~39     !5, 0
         68        SEND_VAL                                                 ~39
         69        DO_ICALL                                         $40     
         70        ADD                                              ~41     $40, 1
         71        ASSIGN_DIM                                               !5, 0
         72        OP_DATA                                                  ~41
   32    73    >   ECHO                                                     !6
   33    74        INIT_FCALL                                               'floor'
         75        FETCH_DIM_R                                      ~42     !5, 1
         76        SEND_VAL                                                 ~42
         77        DO_ICALL                                         $43     
         78        FETCH_DIM_R                                      ~44     !5, 1
         79        IS_NOT_EQUAL                                             $43, ~44
         80      > JMPZ                                                     ~45, ->90
   34    81    >   FETCH_DIM_R                                      ~47     !5, 1
         82        ASSIGN_DIM                                               !1
         83        OP_DATA                                                  ~47
   35    84        INIT_FCALL                                               'floor'
         85        FETCH_DIM_R                                      ~49     !5, 1
         86        SEND_VAL                                                 ~49
         87        DO_ICALL                                         $50     
         88        ASSIGN_DIM                                               !5, 1
         89        OP_DATA                                                  $50
   37    90    >   FETCH_DIM_R                                      ~51     !5, 0
         91        FETCH_DIM_R                                      ~52     !5, 1
         92        IS_SMALLER                                               ~51, ~52
         93      > JMPZ                                                     ~53, ->111
   38    94    >   INIT_FCALL                                               'range'
         95        INIT_FCALL                                               'floor'
         96        FETCH_DIM_R                                      ~54     !5, 0
         97        SEND_VAL                                                 ~54
         98        DO_ICALL                                         $55     
         99        ADD                                              ~56     $55, 1
        100        SEND_VAL                                                 ~56
        101        FETCH_DIM_R                                      ~57     !5, 1
        102        SEND_VAL                                                 ~57
        103        SEND_VAR                                                 !6
        104        DO_ICALL                                         $58     
        105      > FE_RESET_R                                       $59     $58, ->110
        106    > > FE_FETCH_R                                               $59, !7, ->110
   39   107    >   ASSIGN_DIM                                               !1
        108        OP_DATA                                                  !7
   38   109      > JMP                                                      ->106
        110    >   FE_FREE                                                  $59
        111    > > JMP                                                      ->114
   43   112    >   ASSIGN_DIM                                               !1
        113        OP_DATA                                                  !4
   16   114    > > JMP                                                      ->31
        115    >   FE_FREE                                                  $21
   46   116      > FE_RESET_R                                       $62     !1, ->125
        117    > > FE_FETCH_R                                               $62, !8, ->125
   47   118    >   INIT_FCALL                                               'is_numeric'
        119        SEND_VAR                                                 !8
        120        DO_ICALL                                         $63     
        121      > JMPZ                                                     $63, ->124
   48   122    >   ASSIGN_DIM                                               !2
        123        OP_DATA                                                  !8
   46   124    > > JMP                                                      ->117
        125    >   FE_FREE                                                  $62
   51   126        INIT_FCALL                                               'array_unique'
        127        SEND_VAR                                                 !2
        128        DO_ICALL                                         $65     
        129        ASSIGN                                                   !2, $65
   52   130        INIT_FCALL                                               'sort'
        131        SEND_REF                                                 !2
        132        DO_ICALL                                                 
   54   133      > RETURN                                                   !2
   55   134*     > RETURN                                                   null

End of function range_string_to_array

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
257.77 ms | 1411 KiB | 35 Q