Why does this not remove the http:// of the string?
$rurl = 'http://www.google.com';
$httpposi = strpos($rurl,'://');
echo $httpposi;
if($httpposi === true) {
$url=substr($rurl, strpos($rurl, '://') + 3);
echo $url;
} else {
$url=$rurl;
echo '3'.$url.'2';
}
echo $url;
Instead of:
you need:
since if it is found in the string, it will return an offset as an integer, and you are doing a strict comparison and strictly an non-zero, positive integer is not equal to the boolean value
true.so:
If the sequence is found at the beginning of the string, the falsy
0will be returned, thus the need to strictly compare tofalseto know that it has not been found at all.http://ideone.com/QXBs7