$pos = strpos($hostdomain, '.');
if ($pos === false) { /*no point found */}
else
$str = substr($hostdomain,0, $pos);
or much better:
$parts = explode('.', $hostdomain);
and you get all parts of $domain name.
from $hostdomain = "www.behsci.sote.hu"
$parts = array('www', 'behsci', 'sote', '
Richard Kurth wrote:
> I know how to get last part of a string out of a string
> But how do I get the first part before the needle On the example
> below I just what domain
>
> $hostdomain= domain.com
>
> $host = substr (strrchr ($hostdomain, "."), 1);
strrchr (two r) finds the first occur
2 matches
Mail list logo