Created
June 15, 2016 16:00
-
-
Save seredniy/94cc06e105b0a2077d28381f4b2035db 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
// Выдираем айди видео с ютуба | |
function parse_yturl($url) | |
{ | |
$pattern = '#^(?:https?://)?(?:www\.)?(?:youtu\.be/|youtube\.com(?:/embed/|/v/|/watch\?v=|/watch\?.+&v=))([\w-]{11})(?:.+)?$#x'; | |
preg_match($pattern, $url, $matches); | |
return (isset($matches[1])) ? $matches[1] : false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment