Skip to content

Instantly share code, notes, and snippets.

@aliharis
Created November 15, 2012 15:11
Show Gist options
  • Save aliharis/4079091 to your computer and use it in GitHub Desktop.
Save aliharis/4079091 to your computer and use it in GitHub Desktop.
Get YouTube Embed URL
<?php
/**
* Get YouTube Embed URL
* @author Ali Haris (cyberatoll.com)
*/
/**
* @param url
* @return youtube embed url
*/
function getYTEmbedUrl($url){
parse_str(parse_url($url, PHP_URL_QUERY), $vars);
return "http://youtube.com/embed/".$vars['v'];
}
// execution
echo getYTEmbedUrl("http://www.youtube.com/watch?feature=player_embedded&v=er2ajNu49TA");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment