Louk Rath
Louk Rath

Reputation: 33

Get youtubeID from youtube image

I have this youtube image link " http://i1.ytimg.com/vi/W3r-GMq4PZc/0.jpg ". I want to get youtube id only. How to get only youtubeID by using PHP?

Upvotes: 0

Views: 119

Answers (1)

alex
alex

Reputation: 80

Have you looked at questions in the search? Found this: how-to-get-youtube-video-id-from-image-thumbnail-source-and-set-as-an-iframe

You can also use PHP RegExp to extract this is you want:

$subject = "http://i1.ytimg.com/vi/W3r-GMq4PZc/0.jpg";
$pattern = '/[\w\-]{11,}/';
preg_match($pattern, $subject, $matches, PREG_OFFSET_CAPTURE, 3);
print_r($matches);

source: Php preg_match

Upvotes: 1

Related Questions