Created
July 11, 2014 13:41
-
-
Save Sigmus/4d94e039aa7ae08e3064 to your computer and use it in GitHub Desktop.
PHP Regex to get youtube video ID
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 | |
/* | |
* From: http://stackoverflow.com/questions/3392993/php-regex-to-get-youtube-video-id | |
*/ | |
$url = "http://www.youtube.com/watch?v=C4kxS1ksqtw&feature=relate"; | |
parse_str( parse_url( $url, PHP_URL_QUERY ), $my_array_of_vars ); | |
echo $my_array_of_vars['v']; | |
// Output: C4kxS1ksqtw |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment