3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getRange($ip) { $split = explode('.',$ip); $final = array(); foreach ($split as $block) { $pos = strpos($block, '*'); if ($pos !== false) { $num = substr($block, 0, $pos); $l = strlen($block); $min = (int) min(255,str_pad($num,3,'0')); $max = (int) min(255,str_pad($num,3,'9')); $minip = $final; $minip[] = $min; $minip = array_pad($minip, 4, 0); $maxip = $final; $maxip[] = $max; $maxip = array_pad($maxip, 4, 255); return array(implode('.',$minip),implode('.',$maxip)); } $final[] = $block; } return array(implode('.',$final),implode('.',$final)); // No range found. } print_R(getRange("255.2*.0.1"));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jDDXp
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   INIT_FCALL                                               'print_r'
          1        INIT_FCALL                                               'getrange'
          2        SEND_VAL                                                 '255.2%2A.0.1'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
          6      > RETURN                                                   1

Function getrange:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 79
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 79
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 76
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 76
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 79
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 79
filename:       /in/jDDXp
function name:  getRange
number of ops:  92
compiled vars:  !0 = $ip, !1 = $split, !2 = $final, !3 = $block, !4 = $pos, !5 = $num, !6 = $l, !7 = $min, !8 = $max, !9 = $minip, !10 = $maxip
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '.'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $11     
          5        ASSIGN                                                   !1, $11
    4     6        ASSIGN                                                   !2, <array>
    5     7      > FE_RESET_R                                       $14     !1, ->79
          8    > > FE_FETCH_R                                               $14, !3, ->79
    6     9    >   INIT_FCALL                                               'strpos'
         10        SEND_VAR                                                 !3
         11        SEND_VAL                                                 '%2A'
         12        DO_ICALL                                         $15     
         13        ASSIGN                                                   !4, $15
    7    14        TYPE_CHECK                                  1018          !4
         15      > JMPZ                                                     ~17, ->76
    8    16    >   INIT_FCALL                                               'substr'
         17        SEND_VAR                                                 !3
         18        SEND_VAL                                                 0
         19        SEND_VAR                                                 !4
         20        DO_ICALL                                         $18     
         21        ASSIGN                                                   !5, $18
    9    22        STRLEN                                           ~20     !3
         23        ASSIGN                                                   !6, ~20
   10    24        INIT_FCALL                                               'min'
         25        SEND_VAL                                                 255
         26        INIT_FCALL                                               'str_pad'
         27        SEND_VAR                                                 !5
         28        SEND_VAL                                                 3
         29        SEND_VAL                                                 '0'
         30        DO_ICALL                                         $22     
         31        SEND_VAR                                                 $22
         32        DO_ICALL                                         $23     
         33        CAST                                          4  ~24     $23
         34        ASSIGN                                                   !7, ~24
   11    35        INIT_FCALL                                               'min'
         36        SEND_VAL                                                 255
         37        INIT_FCALL                                               'str_pad'
         38        SEND_VAR                                                 !5
         39        SEND_VAL                                                 3
         40        SEND_VAL                                                 '9'
         41        DO_ICALL                                         $26     
         42        SEND_VAR                                                 $26
         43        DO_ICALL                                         $27     
         44        CAST                                          4  ~28     $27
         45        ASSIGN                                                   !8, ~28
   13    46        ASSIGN                                                   !9, !2
   14    47        ASSIGN_DIM                                               !9
         48        OP_DATA                                                  !7
   15    49        INIT_FCALL                                               'array_pad'
         50        SEND_VAR                                                 !9
         51        SEND_VAL                                                 4
         52        SEND_VAL                                                 0
         53        DO_ICALL                                         $32     
         54        ASSIGN                                                   !9, $32
   17    55        ASSIGN                                                   !10, !2
   18    56        ASSIGN_DIM                                               !10
         57        OP_DATA                                                  !8
   19    58        INIT_FCALL                                               'array_pad'
         59        SEND_VAR                                                 !10
         60        SEND_VAL                                                 4
         61        SEND_VAL                                                 255
         62        DO_ICALL                                         $36     
         63        ASSIGN                                                   !10, $36
   21    64        INIT_FCALL                                               'implode'
         65        SEND_VAL                                                 '.'
         66        SEND_VAR                                                 !9
         67        DO_ICALL                                         $38     
         68        INIT_ARRAY                                       ~39     $38
         69        INIT_FCALL                                               'implode'
         70        SEND_VAL                                                 '.'
         71        SEND_VAR                                                 !10
         72        DO_ICALL                                         $40     
         73        ADD_ARRAY_ELEMENT                                ~39     $40
         74        FE_FREE                                                  $14
         75      > RETURN                                                   ~39
   23    76    >   ASSIGN_DIM                                               !2
         77        OP_DATA                                                  !3
    5    78      > JMP                                                      ->8
         79    >   FE_FREE                                                  $14
   25    80        INIT_FCALL                                               'implode'
         81        SEND_VAL                                                 '.'
         82        SEND_VAR                                                 !2
         83        DO_ICALL                                         $42     
         84        INIT_ARRAY                                       ~43     $42
         85        INIT_FCALL                                               'implode'
         86        SEND_VAL                                                 '.'
         87        SEND_VAR                                                 !2
         88        DO_ICALL                                         $44     
         89        ADD_ARRAY_ELEMENT                                ~43     $44
         90      > RETURN                                                   ~43
   26    91*     > RETURN                                                   null

End of function getrange

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.8 ms | 1398 KiB | 30 Q