how to get Video id from url of youtube in php and cakephp
i have this url
http://youtu.be/JaFfJN_iKdA
how to get video id from it by regular expression
how to get Video id from url of youtube in php and cakephp
i have this url
http://youtu.be/JaFfJN_iKdA
how to get video id from it by regular expression
$url = "http://youtu.be/JaFfJN_iKdA";
if (preg_match('%(?:youtube\.com/(?:user/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $url, $result)) {
$video_id = $result[1];
}
That will work for a bunch of common YT URL formats including the one you posted.