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); print_r($split_array);die(); foreach ($split_array as $split1) { if ($split1 === '') { continue; } if (strpos($split1, '-') > -1) { $split = explode('-', $split1); if ($split[0] === '' && $split[1] === '') { continue; } $step = 1; if (floor($split[0]) != $split[0]) { if (floor($split[1]) == $split[1]) { $split[1] = floor($split[0]) . '.' . $split[1]; } $step = '0.1'; } foreach (range($split[0], $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-177'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5UjMG
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   53     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
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/5UjMG
function name:  range_string_to_array
number of ops:  120
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
   17    30        INIT_FCALL                                               'print_r'
         31        SEND_VAR                                                 !3
         32        DO_ICALL                                                 
         33      > EXIT                                                     
   19    34*       FE_RESET_R                                       $22     !3, ->100
         35*       FE_FETCH_R                                               $22, !4, ->100
   20    36*       IS_IDENTICAL                                             !4, ''
         37*       JMPZ                                                     ~23, ->39
   21    38*       JMP                                                      ->35
   23    39*       INIT_FCALL                                               'strpos'
         40*       SEND_VAR                                                 !4
         41*       SEND_VAL                                                 '-'
         42*       DO_ICALL                                         $24     
         43*       IS_SMALLER                                               -1, $24
         44*       JMPZ                                                     ~25, ->97
   24    45*       INIT_FCALL                                               'explode'
         46*       SEND_VAL                                                 '-'
         47*       SEND_VAR                                                 !4
         48*       DO_ICALL                                         $26     
         49*       ASSIGN                                                   !5, $26
   25    50*       FETCH_DIM_R                                      ~28     !5, 0
         51*       IS_IDENTICAL                                     ~29     ~28, ''
         52*       JMPZ_EX                                          ~29     ~29, ->56
         53*       FETCH_DIM_R                                      ~30     !5, 1
         54*       IS_IDENTICAL                                     ~31     ~30, ''
         55*       BOOL                                             ~29     ~31
         56*       JMPZ                                                     ~29, ->58
   26    57*       JMP                                                      ->35
   28    58*       ASSIGN                                                   !6, 1
   29    59*       INIT_FCALL                                               'floor'
         60*       FETCH_DIM_R                                      ~33     !5, 0
         61*       SEND_VAL                                                 ~33
         62*       DO_ICALL                                         $34     
         63*       FETCH_DIM_R                                      ~35     !5, 0
         64*       IS_NOT_EQUAL                                             $34, ~35
         65*       JMPZ                                                     ~36, ->83
   30    66*       INIT_FCALL                                               'floor'
         67*       FETCH_DIM_R                                      ~37     !5, 1
         68*       SEND_VAL                                                 ~37
         69*       DO_ICALL                                         $38     
         70*       FETCH_DIM_R                                      ~39     !5, 1
         71*       IS_EQUAL                                                 $38, ~39
         72*       JMPZ                                                     ~40, ->82
   31    73*       INIT_FCALL                                               'floor'
         74*       FETCH_DIM_R                                      ~42     !5, 0
         75*       SEND_VAL                                                 ~42
         76*       DO_ICALL                                         $43     
         77*       CONCAT                                           ~44     $43, '.'
         78*       FETCH_DIM_R                                      ~45     !5, 1
         79*       CONCAT                                           ~46     ~44, ~45
         80*       ASSIGN_DIM                                               !5, 1
         81*       OP_DATA                                                  ~46
   33    82*       ASSIGN                                                   !6, '0.1'
   35    83*       INIT_FCALL                                               'range'
         84*       FETCH_DIM_R                                      ~48     !5, 0
         85*       SEND_VAL                                                 ~48
         86*       FETCH_DIM_R                                      ~49     !5, 1
         87*       SEND_VAL                                                 ~49
         88*       SEND_VAR                                                 !6
         89*       DO_ICALL                                         $50     
         90*       FE_RESET_R                                       $51     $50, ->95
         91*       FE_FETCH_R                                               $51, !7, ->95
   36    92*       ASSIGN_DIM                                               !1
         93*       OP_DATA                                                  !7
   35    94*       JMP                                                      ->91
         95*       FE_FREE                                                  $51
         96*       JMP                                                      ->99
   39    97*       ASSIGN_DIM                                               !1
         98*       OP_DATA                                                  !4
   19    99*       JMP                                                      ->35
        100*       FE_FREE                                                  $22
   42   101*       FE_RESET_R                                       $54     !1, ->110
        102*       FE_FETCH_R                                               $54, !8, ->110
   43   103*       INIT_FCALL                                               'is_numeric'
        104*       SEND_VAR                                                 !8
        105*       DO_ICALL                                         $55     
        106*       JMPZ                                                     $55, ->109
   44   107*       ASSIGN_DIM                                               !2
        108*       OP_DATA                                                  !8
   42   109*       JMP                                                      ->102
        110*       FE_FREE                                                  $54
   47   111*       INIT_FCALL                                               'array_unique'
        112*       SEND_VAR                                                 !2
        113*       DO_ICALL                                         $57     
        114*       ASSIGN                                                   !2, $57
   48   115*       INIT_FCALL                                               'sort'
        116*       SEND_REF                                                 !2
        117*       DO_ICALL                                                 
   50   118*       RETURN                                                   !2
   51   119*     > RETURN                                                   null

End of function range_string_to_array

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.88 ms | 1407 KiB | 34 Q