开发者

How do I get the Video Id from the URL? (Vimeo)

PHP

<?php

$url = 'http://vimeo.com/25451551';

/* http://www.vimeo.com/25451551 ... www.vimeo.com/25451551 */

$url = preg_matc开发者_JAVA技巧h('???', $url);

echo $url;

?>

Output

25451551

Any help with this would be appreciated. Thanks.


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)


$url = 'http://vimeo.com/25451551/test';
$result = preg_match('/(\d+)/', $url, $matches);
if ($result) {
    var_dump($matches[0]);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜