Last active
March 21, 2017 13:48
-
-
Save Lotuashvili/ef6befd00d659c9eda68271ca1d471cb to your computer and use it in GitHub Desktop.
Filter Youtube link to parse only video ID (for embedding in website)
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 | |
funtion parseYoutubeVideoID($link) { | |
preg_match("/^(?:http(?:s)?:\/\/)?(?:www\.)?(?:m\.)?(?:youtu\.be\/|youtube\.com\/(?:(?:watch)?\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user)\/))([^\?&\"'>]+)/", $link, $matches); | |
return $matches[1]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment