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]; if($i != count($fullArray)-1) $string11 .= '.'; } $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/UgORq
function name:  (null)
number of ops:  13
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     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                                                 
   27     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 = 32
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 24
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 31
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 24
Branch analysis from position: 35
Branch analysis from position: 24
Branch analysis from position: 31
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
filename:       /in/UgORq
function name:  get_last_dot_occurence
number of ops:  40
compiled vars:  !0 = $url, !1 = $fullArray, !2 = $newArray, !3 = $string1, !4 = $i, !5 = $string11
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                                         $6      
          5        ASSIGN                                                   !1, $6
    4     6        ASSIGN                                                   !2, ''
    5     7        COUNT                                            ~9      !1
    6     8        CASE                                                     ~9, 1
          9      > JMPNZ                                                    ~10, ->13
   10    10    >   CASE                                                     ~9, 2
         11      > JMPNZ                                                    ~10, ->15
         12    > > JMP                                                      ->21
    7    13    >   ASSIGN                                                   !2, !0
    8    14      > JMP                                                      ->37
   11    15    >   FETCH_DIM_R                                      ~12     !1, 0
         16        INIT_ARRAY                                       ~13     ~12, 'string1'
         17        FETCH_DIM_R                                      ~14     !1, 1
         18        ADD_ARRAY_ELEMENT                                ~13     ~14, 'string2'
         19        ASSIGN                                                   !2, ~13
   12    20      > JMP                                                      ->37
   15    21    >   ASSIGN                                                   !3, ''
   16    22        ASSIGN                                                   !4, 0
         23      > JMP                                                      ->32
   17    24    >   FETCH_DIM_R                                      ~18     !1, !4
         25        ASSIGN_OP                                     8          !3, ~18
   18    26        COUNT                                            ~20     !1
         27        SUB                                              ~21     ~20, 1
         28        IS_NOT_EQUAL                                             !4, ~21
         29      > JMPZ                                                     ~22, ->31
   19    30    >   ASSIGN_OP                                     8          !5, '.'
   16    31    >   PRE_INC                                                  !4
         32    >   COUNT                                            ~25     !1
         33        IS_SMALLER                                               !4, ~25
         34      > JMPNZ                                                    ~26, ->24
   21    35    >   ASSIGN                                                   !2, !3
   22    36      > JMP                                                      ->37
         37    >   FREE                                                     ~9
   24    38      > RETURN                                                   !2
   25    39*     > RETURN                                                   null

End of function get_last_dot_occurence

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.88 ms | 1403 KiB | 19 Q