How do I get a youtube video ID (PHP)

extract, php, video, youtube

Solution

parse_str(parse_url($url, PHP_URL_QUERY), $variables)
print $variables['v'];

Problem

Given a link from youtube e.g. `http://www.youtube.com/watch?v=XHs99iVpnXU` how do I extract the video id (the v parameter) without it being affected by other parameters such as `feature=` e.g. `http://www.youtube.com/watch?v=XHs99iVpnXU&feature=watch&fullscrenn=true` ?

Original source