var youtubeURL = "https://www.youtube.com/watch?v=U0jqCvnMcFM"; var VideoKey = youtubeURL.substr(youtubeURL.lastIndexOf("v=") + 2, 11); console.log(VideoKey);
- List YouTube channel videos using YouTube Data API in PHP
- Validate YouTube video URL format in PHP using parse_url() function
In the end, we use console.log() method to check if we are able to get the actual ID of the YouTube video or not.
Now you can also put any video URL in the program and check it by yourself. You will able to see the video key in the console log of your browser.