Created
October 9, 2024 04:21
-
-
Save milan-sahana/073f8a89365c902c174974c848945d22 to your computer and use it in GitHub Desktop.
php - get vimeo video id from url
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
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]; | |
} | |
// else | |
// { | |
// $id = substr($url,10,strlen($url)); | |
// } | |
return $id; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment