Reputation:
PHP
<?php
$url = 'http://vimeo.com/25451551';
/* http://www.vimeo.com/25451551 ... www.vimeo.com/25451551 */
$url = preg_match('???', $url);
echo $url;
?>
Output
25451551
Any help with this would be appreciated. Thanks.
Upvotes: 7
Views: 8717
Reputation: 26699
$url = 'http://vimeo.com/25451551/test';
$result = preg_match('/(\d+)/', $url, $matches);
if ($result) {
var_dump($matches[0]);
}
Upvotes: 9
Reputation:
If video IDs are allowed to start with a 0, you may need to tune the following code a bit:
$url = 'http://vimeo.com/25451551';
sscanf(parse_url($url, PHP_URL_PATH), '/%d', $video_id);
// $video_id = int(25451551)
Upvotes: 16