function parse_vimeo($link){
$regexstr = '~
# Match Vimeo link and embed code
(?:< iframe [^>]*src=")? # If iframe match up to first quote of src
(?: # Group vimeo url
https?:\/\/ # Either http or https
(?:[\w]+\.)* # Optional subdomains
vimeo\.com # Match vimeo.com
(?:[\/\w]*\/videos?)? # Optional video sub directory this handles groups links also
\/ # Slash before Id
([0-9]+) # $1: VIDEO_ID is numeric
[^\s]* # Not a space
) # End group
"? # Match end quote if part of src
(?:[^>]*></ iframe >)? # Match the end of the iframe
(?:.*
)? # Match any title information stuff
~ix';
preg_match($regexstr, $link, $matches);
return $matches[1];
}
Thursday, October 15, 2015
Get Vimeo video id from embaded code - PHP
Labels:
Vimeo
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment