3v4l.org

run code in 500+ 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 = 37
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 37
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 30
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 21
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 20
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 20
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 30
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
filename:       /in/C2ADn
function name:  (null)
number of ops:  39
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, ->37
          2    > > FE_FETCH_R                                           ~8      $7, !1, ->37
          3    >   ASSIGN                                                       !2, ~8
   13     4        ASSIGN                                                       !3, !1
   14     5        ASSIGN                                                       !4, 'not+found'
   17     6        FRAMELESS_ICALL_2                strpos              ~12     !1, '%3A'
          7      > JMPZ                                                         ~12, ->30
   19     8    >   FRAMELESS_ICALL_2                str_starts_with      ~13     !1, '%5B'
          9      > JMPZ                                                         ~13, ->21
   20    10    >   FRAMELESS_ICALL_2                strpos              ~14     !1, '%5D%3A'
         11        ASSIGN                                                       !5, ~14
   21    12      > JMPZ                                                         !5, ->20
   23    13    >   ADD                                                  ~16     !5, 2
         14        FRAMELESS_ICALL_2                substr              ~17     !1, ~16
         15        ASSIGN                                                       !4, ~17
   24    16        ADD                                                  ~19     !5, 1
         17        FRAMELESS_ICALL_3                substr              ~20     !1, 0
         18        OP_DATA                                                      ~19
         19        ASSIGN                                                       !3, ~20
   19    20    > > JMP                                                          ->30
   27    21    >   INIT_FCALL                                                   'explode'
         22        SEND_VAL                                                     '%3A'
         23        SEND_VAR                                                     !1
         24        DO_ICALL                                             $22     
         25        FETCH_LIST_R                                         $23     $22, 0
         26        ASSIGN                                                       !3, $23
         27        FETCH_LIST_R                                         $25     $22, 1
         28        ASSIGN                                                       !4, $25
         29        FREE                                                         $22
   31    30    >   CONCAT                                               ~27     !2, '%3A+Hostname%3A+'
         31        CONCAT                                               ~28     ~27, !3
         32        CONCAT                                               ~29     ~28, '+Port%3A+'
         33        CONCAT                                               ~30     ~29, !4
         34        CONCAT                                               ~31     ~30, '%0A'
         35        ECHO                                                         ~31
   12    36      > JMP                                                          ->2
         37    >   FE_FREE                                                      $7
   33    38      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
172.54 ms | 1655 KiB | 14 Q