CODE CODIFY.CLUB

php – get vimeo video id from url

<?php
/*
Get Vimeo video id from url
Supported url formats –

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/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

@param string $url The URL
@return string the video id extracted from url
*/

function getVimeoVideoIdFromUrl($url = ”) {

    $regs = array();
   
    $id = ”;
   
    if (preg_match(‘%^https?://(?:www.|player.)?vimeo.com/(?:channels/(?:w+/)?|groups/([^/]*)/videos/|album/(d+)/video/|video/|)(d+)(?:$|/|?)(?:[?]?.*)$%im’, $url, $regs)) {
        $id = $regs[3];
    }

return $id;

}

?>

V!ral

Developer, Technology aficionado, Beer Lover and founder of codify.club Network. Who shares a keen interest about website development, health issues, cancer awareness and other fun stuff.

Add comment

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.

Most popular

Most discussed