Today I will show you a very easy way to Extract youtube ID from youtube URL in PHP. This is very simple task what shouldn’t take time but we usually do it not official with all of situations.
It ‘s very simple, you just need to run this wayway
function getIDFromYoutubeURL($url){
        $video_id = false;
        if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $url, $match)) {
            $video_id = $match[1];
        }
        return $video_id;
    }Now let ‘s use function like this
$youtubeID = getIDFromYoutubeURL("https://www.youtube.com/watch?v=_URzW7CH8Dg");
// $youtubeID = _URzW7CH8Dg
 WP2X We can help your Wordpress faster
WP2X We can help your Wordpress faster  
 
 
   
   
   
   
  