3v4l.org

run code in 300+ PHP versions simultaneously
<?php $values = [ 'ip' => '127.0.0.1', 'hostname' => 'localhost', 'ipport' => '127.0.0.1:3307', 'hostname' => 'localhost:3308', 'ipv6' => '[2001:0DB8::1234]', 'ipv6port' => '[2001:0DB8::1234]:3309', ]; foreach($values as $k=>$hostport) { $host = 'not found'; $port = 'not found'; // has port or ipv6 if (strpos($hostport, ':')) { // ipv6 if (str_starts_with($hostport, '[')) { $portposition = strpos($hostport,']:'); if ($portposition) { $port = substr($hostport, $portposition+2); $host = substr($hostport, 0, $portposition+1); } else { $host = $hostport; } } else { [$host, $port] = explode(':', $hostport); } } else { $host = $hostport; // ipv4/domainname without port } echo $k .': Hostname: ' . $host . ' Port: ' . $port ."\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 56
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 56
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 48
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 38
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 36
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 56
filename:       /in/oFFaE
function name:  (null)
number of ops:  58
compiled vars:  !0 = $values, !1 = $hostport, !2 = $k, !3 = $host, !4 = $port, !5 = $portposition
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   12     1      > FE_RESET_R                                       $7      !0, ->56
          2    > > FE_FETCH_R                                       ~8      $7, !1, ->56
          3    >   ASSIGN                                                   !2, ~8
   13     4        ASSIGN                                                   !3, 'not+found'
   14     5        ASSIGN                                                   !4, 'not+found'
   17     6        INIT_FCALL                                               'strpos'
          7        SEND_VAR                                                 !1
          8        SEND_VAL                                                 '%3A'
          9        DO_ICALL                                         $12     
         10      > JMPZ                                                     $12, ->48
   19    11    >   INIT_FCALL                                               'str_starts_with'
         12        SEND_VAR                                                 !1
         13        SEND_VAL                                                 '%5B'
         14        DO_ICALL                                         $13     
         15      > JMPZ                                                     $13, ->38
   20    16    >   INIT_FCALL                                               'strpos'
         17        SEND_VAR                                                 !1
         18        SEND_VAL                                                 '%5D%3A'
         19        DO_ICALL                                         $14     
         20        ASSIGN                                                   !5, $14
   21    21      > JMPZ                                                     !5, ->36
   23    22    >   INIT_FCALL                                               'substr'
         23        SEND_VAR                                                 !1
         24        ADD                                              ~16     !5, 2
         25        SEND_VAL                                                 ~16
         26        DO_ICALL                                         $17     
         27        ASSIGN                                                   !4, $17
   24    28        INIT_FCALL                                               'substr'
         29        SEND_VAR                                                 !1
         30        SEND_VAL                                                 0
         31        ADD                                              ~19     !5, 1
         32        SEND_VAL                                                 ~19
         33        DO_ICALL                                         $20     
         34        ASSIGN                                                   !3, $20
   21    35      > JMP                                                      ->37
   26    36    >   ASSIGN                                                   !3, !1
   19    37    > > JMP                                                      ->47
   29    38    >   INIT_FCALL                                               'explode'
         39        SEND_VAL                                                 '%3A'
         40        SEND_VAR                                                 !1
         41        DO_ICALL                                         $23     
         42        FETCH_LIST_R                                     $24     $23, 0
         43        ASSIGN                                                   !3, $24
         44        FETCH_LIST_R                                     $26     $23, 1
         45        ASSIGN                                                   !4, $26
         46        FREE                                                     $23
   17    47    > > JMP                                                      ->49
   33    48    >   ASSIGN                                                   !3, !1
   36    49    >   CONCAT                                           ~29     !2, '%3A+Hostname%3A+'
         50        CONCAT                                           ~30     ~29, !3
         51        CONCAT                                           ~31     ~30, '+Port%3A+'
         52        CONCAT                                           ~32     ~31, !4
         53        CONCAT                                           ~33     ~32, '%0A'
         54        ECHO                                                     ~33
   12    55      > JMP                                                      ->2
         56    >   FE_FREE                                                  $7
   38    57      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
121.44 ms | 1434 KiB | 17 Q