I want to clean the url addres but first I want to check if what should be replace is in the string. I want to use strpos because is faster, but it fails to detect the string.
$txt = 'http://www.youtube.com/watch?v=aWFmXFFjJfw';
if(strpos($txt, 'http://www.')){
echo 'true strpos'; // not shows
}
if(strstr($txt, 'http://www.')){
echo 'true strstr'; // show
}
Also
$match = strpos($txt, 'http://www.');
var_dump($match); // int(0);
Because it equals 0 which equates to false.
Instead use:
if(strpos($txt, 'http://www.')!==false){
echo 'true strpos'; //shows
}