Using PHP code you can easily extract video ID of any youtube video. You can feed the input as the youtube video
Youtube video urls can of these types:
Shortened Youtube Video URL
Normal Youtube Video URL
Usually the video url can of the above two types. And we need to extract the video ID from both types of url inputs.
For both the video ID is:
-RdRvv60X2k
PHP CODE for Youtube Video ID extraction from Video URL
<?php
$video_url = 'https://youtu.be/-RdRvv60X2k'; //pass the url here
$substr = "=";
if (strpos($str, $substr) !== false) {
$url_arr = explode("=",$video_url);
$video_id = $url_arr[1];
echo $video_id;
}else{
$url_arr = explode("/",$video_url);
$video_id = $url_arr[3];
echo $video_id;
}
?>
Output: -RdRvv60X2k
Tags: Get video id from youtube, youtube video Id extraction, get