Created
June 10, 2019 06:01
-
-
Save sushat4692/44ed8b0f361c897462e56f16846be391 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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