Skip to content

Instantly share code, notes, and snippets.

@sushat4692
Created June 10, 2019 06:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sushat4692/44ed8b0f361c897462e56f16846be391 to your computer and use it in GitHub Desktop.
Save sushat4692/44ed8b0f361c897462e56f16846be391 to your computer and use it in GitHub Desktop.
<?php
// Convert Movie URL
function getMovieUrl($movieUrl)
{
// Convert YouTube Url
if (
strpos($movieUrl, 'youtu.be') !== false ||
strpos($movieUrl, 'youtube.com/watch') !== false
) {
$movieId = str_replace(array('https://youtu.be/', 'https://www.youtube.com/watch?v=', 'https://www.youtube.com/watch/'), '', $movieUrl);
return 'https://www.youtube.com/embed/' . $movieId;
}
return $movieUrl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment