Skip to content

Instantly share code, notes, and snippets.

View Jthe4th's full-sized avatar

John Feezer IV Jthe4th

View GitHub Profile
@aalaap
aalaap / fn.quickYouTubeId.php
Last active February 5, 2019 10:55
Easy little function to get the video ID from any YouTube URL.
<php
/**
* quickYouTubeId: Easy little function to get the video ID from any YouTube
* URL.
*
* I went through a lot of snippets that perform various kinds of RegEx and
* parse_url and what not, but I thought, since most YouTube video IDs are 11
* characters, why not just look for the only 11-character string and extract
* that? I can't think of a YouTube URL that'll foil this match. Can you?
*