Last active
October 7, 2023 18:02
-
-
Save tarecord/dd9732f69bf5ef6080be2e2ecdac0a23 to your computer and use it in GitHub Desktop.
A function that takes a vimeo url and returns the video ID
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
<?php | |
function get_vimeo_id( $url ) { | |
/** | |
* Matches: | |
* https://player.vimeo.com/video/123456789 | |
* https://vimeo.com/123456789 | |
* https://www.vimeo.com/123456789 | |
*/ | |
preg_match( '/(vimeo\.com\/)(?:video\/)?([\d]+)/', $url, $matches ); | |
$vimeo_id = $matches[2]; | |
return $vimeo_id; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment