Why would you just
$url = "http://www.youtube.com/watch?feature=v-feature&v=317a815FLWQ&hello=ok";
$stop = strlen($url);
$pos = strpos($url,'v=')+2;
$x = strpos($url,'&',$pos);
if($x)
{
$x = $x - $pos;
$stop = $x;
}
$str = substr($url,$pos,$stop);
echo $str;
It basically always starts with v = ....
source
share