Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get vine video id using php

Tags:

php

I need to get the vine video id from the url

so the output from link like this

https://vine.co/v/bXidIgMnIPJ

be like this

bXidIgMnIPJ

I tried to use code form other question here for Vimeo (NOT VINE) Get img thumbnails from Vimeo?

This what I tried to use but I did not succeed

$url = 'https://vine.co/v/bXidIgMnIPJ';

preg_replace('~^https://(?:www\.)?vine\.co/(?:clip:)?(\d+)~','$1',$url)
like image 314
Jim Avatar asked May 14 '26 16:05

Jim


2 Answers

basename maybe?

<?php
$url = 'https://vine.co/v/bXidIgMnIPJ';
var_dump(basename($url));    

http://codepad.org/vZiFP27y

like image 93
Jonathan Kuhn Avatar answered May 17 '26 06:05

Jonathan Kuhn


Assuming it will always be in that format, you can just split the url by the / delimiter. Regex is not needed for a simple url such as this.

$id = end(explode('/', $url));
like image 35
Austin Brunkhorst Avatar answered May 17 '26 04:05

Austin Brunkhorst



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!