Skip to content

Instantly share code, notes, and snippets.

@dnshulga
Created October 9, 2023 22:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnshulga/9e9a3bbf887d3d8b98765cc1ecb9b908 to your computer and use it in GitHub Desktop.
Save dnshulga/9e9a3bbf887d3d8b98765cc1ecb9b908 to your computer and use it in GitHub Desktop.
Get Youtube ID function
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