$str = 'https://example.com/tools/onphp.html';
echo strpos($str,'/',0); //return 6
echo strpos($str,'/',1); //return 6
echo strpos($str,'/',2); //return 6
echo strpos($str,'/',3); //return 6
in php 7.3
why is the result returned 6666
i want get result is 'https://www.example.com/' use substr($str,0,strpos($str,'/',2));
but it can not working
now i'm use
preg_replace('/^([\s\S]*?)\/\/([\s\S]*?)\/([\s\S]*?)$/','\1//\2',$str);
so is there a simpler solution ?