Question: Write a PHP function 'getTLD' that accepts a domain name (such as www.google.com) as a single string argument and returns the top-level domain, the right-most

Write a PHP function 'getTLD' that accepts a domain name (such as www.google.com) as a single string argument and returns the top-level domain, the right-most portion, of that domain (com).

Note that fully qualified domains actually end in a period (www.google.com.). It is optional when displayed and often not included. Your fuction, however, should account for this as shown in the third example.

getTLD("iit.edu"); // returns "edu" getTLD("www.bob.smith.info"); // returns "info" (even though it is not just three characters) getTLD("w3.org."); // returns "org" (without the trailing period)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!