Created
June 7, 2013 13:00
-
-
Save arnabc/5729070 to your computer and use it in GitHub Desktop.
A simple PHP code which parses the Youtube links from a text(paragraph) and then finds the video id from the URL.
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
// Pseudo code (Not for production) | |
$link_regex = "/(http|https)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/g" | |
preg_match_all($link_regex, $your_paragrah, $links_array) | |
// loop through links array and use the following code to parse url and variable | |
parse_str(parse_url( $url, PHP_URL_QUERY ), $vars ); | |
echo $vars['v']; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment