Here’s a handy PHP code snippet which allows you to extract the video ID of a YouTube video from URL. All you need to do is pass the YouTube URL to the getYouTubeId() function.
//get video id from youtube url function getYouTubeId($url){ parse_str( parse_url( $url, PHP_URL_QUERY ), $my_array_of_vars ); return $my_array_of_vars['v']; } echo getYouTubeId('https://www.youtube.com/watch?v=y2Ky3Wo37AY');
The Above code will output,
y2Ky3Wo37AY
0 comments:
Post a Comment