Search

Apr 25, 2016

PHP Get Id youtube from URL link

<?php
if (strpos($video, 'youtube') > 0) {
    preg_match("#(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=v\/)[^&\n]+(?=\?)|(?<=v=)[^&\n]+|(?<=youtu.be/)[^&\n]+#", $video, $matches);
    $_video = 'https://www.youtube.com/embed/' . $matches[0];
}

No comments:

Post a Comment