I have the following code that grabs the youtube video id from old shared urls (youtube.com/watch?v=adasdalkjsd)
$url = $_GET['url'];
parse_str(parse_url($url, PHP_URL_QUERY), $query);
$video_id = isset($query['v']) ? $query['v'] : NULL;
which works for the old ones, but I need a system that can work for both URLs. any suggestions?
source
share