|
Posted by Rik on 08/05/06 16:04
Miguel Cruz wrote:
> "Eric Rechter" <erikrechter@solcon.nl> wrote:
>> I only want to display the provider name from a hostname, so I need
>> to divide the string to take only de characters from after the
>> before last dot.
>>
>> For example:
>>
>> dsl-083-247-088-130.solcon.nl -> I only wanna display "solcon.nl"
>
> $hostname = "dsl-083-247-088-130.solcon.nl";
> $parts = explode('.', $hostname);
> if (count($parts) >= 2)
> $provider_name =
> $parts[count($parts) - 2] . '.' . $parts[count($parts) - 1];
> else
> $provider_name = $hostname;
Well, if we're going that way:
$host = implode('.',array_slice(explode('.',$hostname),-2));
Grtz,
--
Rik Wasmus
Navigation:
[Reply to this message]
|