Skip to content

Instantly share code, notes, and snippets.

@milan-sahana
Created October 9, 2024 04:21
Show Gist options
  • Save milan-sahana/073f8a89365c902c174974c848945d22 to your computer and use it in GitHub Desktop.
Save milan-sahana/073f8a89365c902c174974c848945d22 to your computer and use it in GitHub Desktop.
php - get vimeo video id 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];
}
// 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