Created
October 9, 2023 22:34
-
-
Save dnshulga/9e9a3bbf887d3d8b98765cc1ecb9b908 to your computer and use it in GitHub Desktop.
Get Youtube ID function
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 getYouTubeID($url){ | |
preg_match("/^(?:http(?:s)?:\/\/)?(?:www\.)?(?:m\.)?(?:youtu\.be\/|youtube\.com\/(?:(?:watch)?\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user)\/))([^\?&\"'>]+)/", $url, $matches); | |
return $matches[1]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment