Possible Duplicate:
parse youtube video id using preg_match
Grab the video ID only from youtube's URLs
I use something like this now but i get a lot of errors...
$video_id = $_GET['url'];
$video_id = str_replace('http://www.youtube.com/watch?v=','',$video_id);
$video_id = str_replace('&feature=related','',$video_id);
$video_id = str_replace('&feature=fvwrel','',$video_id);
$video_id = str_replace('&hd=1','',$video_id);
$video_id = str_replace('&feature=relmfu','',$video_id);
$video_id = str_replace('&feature=channel_video_title','',$video_id);
$video_id = str_replace('&feature=list_related','',$video_id);
$video_id = str_replace('&playnext=1','',$video_id);
$video_id = str_replace('_player','',$video_id);
The problem is that youtube has multiple url variables for '&feature=' and maybe others
The only thing i want to extract from the youtube url is the unique video id
ex: //www.youtube.com/watch?v=lgT1AidzRWM&feature=related
and nothing after the id or before
can someone help me to get it?