- var_dump: documentation ( source)
- preg_match: documentation ( source)
<?php
function _getYoutubeVideoId($url)
{
if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $url, $match)) {
return $match[1];
}
}
var_dump(_getYoutubeVideoId("http://www.youtube.com/user/username#p/u/11/WQq0RAbj4i8"));