Last active
December 29, 2017 17:38
-
-
Save yusufhm/5c84ffe3557f9cbda4eb8cb8bd156206 to your computer and use it in GitHub Desktop.
php regex
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
<?php | |
// YouTube id from url. | |
// @see http://stackoverflow.com/a/6382259/351590 | |
if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $url, $match)) { | |
$video_id = $match[2]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment