You might want to consider an explode() argument instead of an expression (unless you plan on having www. in your database in which case you would need to modify the array below).
For example :
$url = test.com
$pieces = explode(".", $url);
$new_url = $pieces[0];
print "$new_url"; // would output "test"
Stephen wrote:
Hi
I am writing a PHP domain check that covers tld's and uk sld's. However to make a create a loop to check more than one domain at once I need to extract the first part of the domain inputted by a user.
For example if someone inputted:
test.com
I would need to extract test from test.com so far I can extract the com from test.com using:
$tld = ereg("([.]*$)", $domain, $regs) ;
if anyone could also show me how to get test from test.co.uk I would be very grateful.
Regards,
Stephen