function convertYoutube($string) {
return preg_replace(
"/\s*[a-zA-Z\/\/:\.]*youtu(be.com\/watch\?v=|.be\/)([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i",
"",
$string
);
}
$text = "Youtube long url: https://www.youtube.com/watch?v=waIkasvAVGo \nYoutube short url: http://youtu.be/waIkasvAVGo ";
echo convertYoutube($text);
?>
Böyle bir örnek buldum. $text yerine formdan gelen veriyi kullanırsın.