Created
August 23, 2011 11:52
-
-
Save bpierre/1164929 to your computer and use it in GitHub Desktop.
Parse video providers
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 Robbie Player: https://forrst.com/posts/Grab_Youtube_or_Vimeo_Info_with_PHP-0el#comment-150356 | |
function video_url_to_id($url, $provider) { | |
$video_id = FALSE; | |
$url = parse_url($url); | |
switch ($provider) { | |
case 'youtube': | |
$vid = parse_str($url['query'], $output); | |
$video_id = $output['v']; | |
break; | |
case 'vimeo': | |
$video_id = str_replace("/", "", $url['path']); | |
break; | |
} | |
return $video_id; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment