3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_last_dot_occurence ($url ) { $fullArray = explode('.', $url); $newArray = ""; switch (count($fullArray)) { case 1: $newArray = $url; break; case 2: $newArray = array("string1" => $fullArray[0], "string2" => $fullArray[1]); break; default: $string1 = ""; for ($i=0; $i < count($fullArray); $i++) { $string1 .= $fullArray[$i].'.'; } $newArray = $string1; break; } return $newArray; } print_r(get_last_dot_occurence("test.com")); print_r(get_last_dot_occurence("1.2.test.com"));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FgIvF
function name:  (null)
number of ops:  13
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_FCALL                                               'print_r'
          1        INIT_FCALL                                               'get_last_dot_occurence'
          2        SEND_VAL                                                 'test.com'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
   25     6        INIT_FCALL                                               'print_r'
          7        INIT_FCALL                                               'get_last_dot_occurence'
          8        SEND_VAL                                                 '1.2.test.com'
          9        DO_FCALL                                      0  $2      
         10        SEND_VAR                                                 $2
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Function get_last_dot_occurence:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 24
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 24
Branch analysis from position: 31
Branch analysis from position: 24
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
filename:       /in/FgIvF
function name:  get_last_dot_occurence
number of ops:  36
compiled vars:  !0 = $url, !1 = $fullArray, !2 = $newArray, !3 = $string1, !4 = $i
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                                         $5      
          5        ASSIGN                                                   !1, $5
    4     6        ASSIGN                                                   !2, ''
    5     7        COUNT                                            ~8      !1
    6     8        CASE                                                     ~8, 1
          9      > JMPNZ                                                    ~9, ->13
   10    10    >   CASE                                                     ~8, 2
         11      > JMPNZ                                                    ~9, ->15
         12    > > JMP                                                      ->21
    7    13    >   ASSIGN                                                   !2, !0
    8    14      > JMP                                                      ->33
   11    15    >   FETCH_DIM_R                                      ~11     !1, 0
         16        INIT_ARRAY                                       ~12     ~11, 'string1'
         17        FETCH_DIM_R                                      ~13     !1, 1
         18        ADD_ARRAY_ELEMENT                                ~12     ~13, 'string2'
         19        ASSIGN                                                   !2, ~12
   12    20      > JMP                                                      ->33
   15    21    >   ASSIGN                                                   !3, ''
   16    22        ASSIGN                                                   !4, 0
         23      > JMP                                                      ->28
   17    24    >   FETCH_DIM_R                                      ~17     !1, !4
         25        CONCAT                                           ~18     ~17, '.'
         26        ASSIGN_OP                                     8          !3, ~18
   16    27        PRE_INC                                                  !4
         28    >   COUNT                                            ~21     !1
         29        IS_SMALLER                                               !4, ~21
         30      > JMPNZ                                                    ~22, ->24
   19    31    >   ASSIGN                                                   !2, !3
   20    32      > JMP                                                      ->33
         33    >   FREE                                                     ~8
   22    34      > RETURN                                                   !2
   23    35*     > RETURN                                                   null

End of function get_last_dot_occurence

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.88 ms | 1403 KiB | 19 Q