-1

Possible Duplicate:
regex pattern to get Youtube ID from any Youtube URL

I would like to know how to trim a part of a URL like "http://www.youtube.com/watch?v=I4_3PVFSUxE&feature=plcp" and it will only output "I4_3PVFSUxE".

So I want to get the code that is after "v=" and delete whatever is after that.

Community
  • 1
  • 1
John Smith
  • 49
  • 5

1 Answers1

2

You could use...

$query = parse_url($url, PHP_URL_QUERY);

parse_str($query, $queryParts);

$v = $queryParts['v'];

if (get_magic_quotes_gpc()) {
    $v = stripslashes($v);
}

CodePad.

alex
  • 479,566
  • 201
  • 878
  • 984