3v4l.org

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

End of function get_last_dot_occurence

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.1 ms | 1407 KiB | 20 Q