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

End of function range_string_to_array

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
195.18 ms | 1410 KiB | 34 Q