Last active
October 26, 2017 20:41
-
-
Save talkahe/31f9ec351a9d874a1993211464e35045 to your computer and use it in GitHub Desktop.
Expresión regular ID video Youtube
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//obetener la id del video de youtube | |
$url = $_POST["video"]; | |
preg_match("#(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=v\/)[^&\n]+(?=\?)|(?<=v=)[^&\n]+|(?<=youtu.be/)[^&\n]+#", $url, $matches); | |
$video = $matches[0]; | |
if($video==""){ | |
echo "La URL debe ser un enlace a Youtube."; | |
die(); | |
}else{ | |
echo "OK."; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment