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)-2; $i++) { $string1 .= $fullArray[$i]; if($i != count($fullArray)-3) $string1 .= '.'; } $string2 = $fullArray[count($fullArray)-2].'.'.$fullArray[count($fullArray)-1]; $newArray = array("string1" => $string1, "string2" => $string2); break; } return $newArray; } print_r(get_last_dot_occurence("abc.com")); print_r(get_last_dot_occurence("abc.name.com")); print_r(get_last_dot_occurence("abc.xyz.name.com"));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1kKGa
function name:  (null)
number of ops:  19
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'print_r'
          1        INIT_FCALL                                               'get_last_dot_occurence'
          2        SEND_VAL                                                 'abc.com'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
   28     6        INIT_FCALL                                               'print_r'
          7        INIT_FCALL                                               'get_last_dot_occurence'
          8        SEND_VAL                                                 'abc.name.com'
          9        DO_FCALL                                      0  $2      
         10        SEND_VAR                                                 $2
         11        DO_ICALL                                                 
   29    12        INIT_FCALL                                               'print_r'
         13        INIT_FCALL                                               'get_last_dot_occurence'
         14        SEND_VAL                                                 'abc.xyz.name.com'
         15        DO_FCALL                                      0  $4      
         16        SEND_VAR                                                 $4
         17        DO_ICALL                                                 
         18      > 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 = 36, Position 2 = 24
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
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 = 36, Position 2 = 24
Branch analysis from position: 36
Branch analysis from position: 24
Branch analysis from position: 31
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
filename:       /in/1kKGa
function name:  get_last_dot_occurence
number of ops:  52
compiled vars:  !0 = $url, !1 = $fullArray, !2 = $newArray, !3 = $string1, !4 = $i, !5 = $string2
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                                                      ->49
   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                                                      ->49
   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, 3
         28        IS_NOT_EQUAL                                             !4, ~21
         29      > JMPZ                                                     ~22, ->31
   19    30    >   ASSIGN_OP                                     8          !3, '.'
   16    31    >   PRE_INC                                                  !4
         32    >   COUNT                                            ~25     !1
         33        SUB                                              ~26     ~25, 2
         34        IS_SMALLER                                               !4, ~26
         35      > JMPNZ                                                    ~27, ->24
   21    36    >   COUNT                                            ~28     !1
         37        SUB                                              ~29     ~28, 2
         38        FETCH_DIM_R                                      ~30     !1, ~29
         39        CONCAT                                           ~31     ~30, '.'
         40        COUNT                                            ~32     !1
         41        SUB                                              ~33     ~32, 1
         42        FETCH_DIM_R                                      ~34     !1, ~33
         43        CONCAT                                           ~35     ~31, ~34
         44        ASSIGN                                                   !5, ~35
   22    45        INIT_ARRAY                                       ~37     !3, 'string1'
         46        ADD_ARRAY_ELEMENT                                ~37     !5, 'string2'
         47        ASSIGN                                                   !2, ~37
   23    48      > JMP                                                      ->49
         49    >   FREE                                                     ~9
   25    50      > RETURN                                                   !2
   26    51*     > RETURN                                                   null

End of function get_last_dot_occurence

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.93 ms | 1402 KiB | 20 Q