I got this code:
if(preg_match("/^(?:https?:\/\/)?(?:www\.)?youtu(.be\/|be\.com\/watch\?v=)(\w{11})$/", $url)){
preg_match("/^(?:https?:\/\/)?(?:www\.)?youtu(.be\/|be\.com\/watch\?v=)(\w{11})$/", $url, $matches);
$vid = str_replace(' ', '', $matches[0]);
}
That pretty much checks if the URL is a Youtube video. How do I assign the last 11 characters from the URL to the $vid
variable?
Example:
URL: https://www.youtube.com/watch?v=ASDASDASDAS
$vid = ASDASDASDAS