Just suppose we have a string as below:-
<?php
$str = 'http://blog.phpmypassion.com';?>
Now If I want to get my main domain then I have to follow below code..
<?php
if(($pos = strpos($str, '.')) !== false)
{
$new_str = substr($str, $pos + 1);
}
else
{
$new_str = get_last_word($str);
}
echo 'new string will be='.$new_str;?>
Output:-
So the output will be "new string will be=phpmypassion.com"It is a easiest way to remove everything before a specific characters position.
Note: Only a member of this blog may post a comment.