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 = $hostport; $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, $port] = explode(':', $hostport); } } 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 = 52
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 52
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 45
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 36
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 35
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 35
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 45
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 52
filename:       /in/C2ADn
function name:  (null)
number of ops:  54
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, ->52
          2    > > FE_FETCH_R                                       ~8      $7, !1, ->52
          3    >   ASSIGN                                                   !2, ~8
   13     4        ASSIGN                                                   !3, !1
   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, ->45
   19    11    >   INIT_FCALL                                               'str_starts_with'
         12        SEND_VAR                                                 !1
         13        SEND_VAL                                                 '%5B'
         14        DO_ICALL                                         $13     
         15      > JMPZ                                                     $13, ->36
   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, ->35
   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
   19    35    > > JMP                                                      ->45
   27    36    >   INIT_FCALL                                               'explode'
         37        SEND_VAL                                                 '%3A'
         38        SEND_VAR                                                 !1
         39        DO_ICALL                                         $22     
         40        FETCH_LIST_R                                     $23     $22, 0
         41        ASSIGN                                                   !3, $23
         42        FETCH_LIST_R                                     $25     $22, 1
         43        ASSIGN                                                   !4, $25
         44        FREE                                                     $22
   31    45    >   CONCAT                                           ~27     !2, '%3A+Hostname%3A+'
         46        CONCAT                                           ~28     ~27, !3
         47        CONCAT                                           ~29     ~28, '+Port%3A+'
         48        CONCAT                                           ~30     ~29, !4
         49        CONCAT                                           ~31     ~30, '%0A'
         50        ECHO                                                     ~31
   12    51      > JMP                                                      ->2
         52    >   FE_FREE                                                  $7
   33    53      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
135.35 ms | 1434 KiB | 17 Q