You can use the regular expression
Sorry a small mistake instead of 3 use 4 ie mathes[4]...
I think it may be helpful for you
$host= "www.networkstuff.co.nz";
preg_match('/^(w{3})\.([a-zA-Z]+)\.([a-zA-z]{2})\.([a-zA-z]{2})/', $host,
$matches);
$returnedString = $matches[4]
echo $returnedString;
Regards
Renjith
On Mon, Jan 26, 2009 at 10:08 PM, renjith das <[email protected]> wrote:
> You can use the regular expression
>
> I think it may be helpful for you
>
> $host= "www.networkstuff.co.nz";
>
> preg_match('/^(w{3})\.([a-zA-Z]+)\.([a-zA-z]{2})\.([a-zA-z]{2})/', $host,
> $matches);
> $returnedString = $matches[3]
> echo $returnedString;
>
> Regards
> Renjith
>
>
>
> On Mon, Jan 26, 2009 at 9:20 PM, Michael <[email protected]>wrote:
>
>>
>> What I need to do is grab the TLD from a URL string-
>>
>> eg: www.networkstuff.co.nz - what I want returned is the 'nz' part.
>>
>> What is the best way to achieve this?
>>
>> Thanks in anticipation.
>>
>> Michael
>>
>> >>
>>
>
--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]
-~----------~----~----~----~------~----~------~--~---