-
-
Save pavlo-bondarchuk/869031b59e181d82ec0609df51e161c7 to your computer and use it in GitHub Desktop.
convert url youtube/watch to youtube/embed
This file contains hidden or 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 | |
$url = 'https://www.youtube.com/watch?v=u9-kU7gfuFA'; | |
preg_match('/[\\?\\&]v=([^\\?\\&]+)/', $url, $matches); | |
$id = $matches[1]; | |
$width = '800px'; | |
$height = '450px'; | |
?> | |
<iframe id="ytplayer" type="text/html" width="<?php echo $width ?>" height="<?php echo $height ?>" | |
src="https://www.youtube.com/embed/<?php echo $id ?>?rel=0&showinfo=0&color=white&iv_load_policy=3" | |
frameborder="0" allowfullscreen></iframe> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment