Skip to content

Instantly share code, notes, and snippets.

@1271
Created January 28, 2019 19:01
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 1271/5ee00cdfa0beed0abbe2600afa8dfb20 to your computer and use it in GitHub Desktop.
Save 1271/5ee00cdfa0beed0abbe2600afa8dfb20 to your computer and use it in GitHub Desktop.
Youtube url extract
<?php
if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $url, $match)) {
$video_id = $match[1];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment