erknrio of Programming Guanches
8/21/2015 - 8:02 AM

Obtener el id de vimeo con https opcional. FROM: https://gist.github.com/erknrio/97a62bfbe5d2f77158c3

Obtener el id de vimeo con https opcional. FROM: https://gist.github.com/erknrio/97a62bfbe5d2f77158c3

<?php
function vimeoID($url) {
	if (preg_match("/https?:\/\/(?:www\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|)(\d+)(?:$|\/|\?)/", $url, $id)) {
		return "<strong>".$id[3]."</strong>";
	} else {
    	return "<strong class='error'>error</strong>";
	}
}

$vimeo = array(
"https://vimeo.com/11111111",
"http://vimeo.com/11111111",
"https://www.vimeo.com/11111111",
"http://www.vimeo.com/11111111",
"https://vimeo.com/channels/11111111",
"http://vimeo.com/channels/11111111",
"https://vimeo.com/channels/mychannel/11111111",
"http://vimeo.com/channels/yourchannel/11111111",
"https://vimeo.com/groups/name/videos/11111111",
"http://vimeo.com/groups/name/videos/11111111",
"https://vimeo.com/album/2222222/video/11111111",
"http://vimeo.com/album/2222222/video/11111111",
"https://vimeo.com/11111111?param=test",
"http://vimeo.com/11111111?param=test"
);

echo "<ul>";
foreach ($vimeo as $video) {
	echo "<li>".$video.": ".vimeoID($video)."</li>";
}
echo "<ul>";

?>