Show YouTube vedio in php

## GET YOUTUBE VEDIO  <?php  function getYoutubeEmbedUrl($url) { $shortUrlRegex = ‘/youtu.be\/([a-zA-Z0-9_]+)\??/i’; $longUrlRegex = ‘/youtube.com\/((?:embed)|(?:watch))((?:\?v\=)|(?:\/))(\w+)/i’; if (preg_match($longUrlRegex, $url, $matches)) { $youtube_id = $matches[count($matches) – 1]; } if (preg_match($shortUrlRegex, $url, $matches)) { $youtube_id = $matches[count($matches) – 1]; } return ‘https://www.youtube.com/embed/’ . $youtube_id ; } //call function and get the link: $embedUrl = getYoutubeEmbedUrl($d[‘link’]); ?>

How to show YouTube vedio using youtube link in php

## GET YOUTUBE VEDIO <?php function getYoutubeEmbedUrl($url) { $shortUrlRegex = ‘/youtu.be\/([a-zA-Z0-9_]+)\??/i’; $longUrlRegex = ‘/youtube.com\/((?:embed)|(?:watch))((?:\?v\=)|(?:\/))(\w+)/i’; if (preg_match($longUrlRegex, $url, $matches)) { $youtube_id = $matches[count($matches) – 1]; } if (preg_match($shortUrlRegex, $url, $matches)) { $youtube_id = $matches[count($matches) – 1]; } return ‘https://www.youtube.com/embed/‘ . $youtube_id ; } //call function and get the link: $embedUrl = getYoutubeEmbedUrl($link); ?> <!– Showing Youtube Vedio –> … Read moreHow to show YouTube vedio using youtube link in php