/ Published in: PHP
Returns the video id for any type of youtube url that holds one.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Returns the video id for any type of youtube url that holds one, like the links bellow. http://www.youtube.com/watch?v=pkPgYbdQ1kQ&feature=feedu www.youtube.com/watch?v=pkPgYbdQ1kQ&feature=feedu youtube.com/watch?v=pkPgYbdQ1kQ&feature=feedu http://www.youtube.com/v/pkPgYbdQ1kQ&feature=feedu www.youtube.com/v/pkPgYbdQ1kQ&feature=feedu http://youtu.be/pkPgYbdQ1kQ youtu.be/pkPgYbdQ1kQ |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/ function uTubeId($url){ $url = preg_replace('((http://)?(www.)?(youtube.com|youtu.be)(/v/|/watch\?v=|/)([a-zA-Z0-9_-]*)(.*))',"$5",$url); }