Unable to figure out why the following code doesn't work.
It takes text file content (string), replaces the youtube url (from the string) then embed it to other string, but I am getting no response.
// regex
$yt_pre = "/https?:\/\/(?:www)?\.youtu(?:\.be|be\.com)\/watch(?:\?(.*?)&|\?)v=([a-zA-Z0-9_\-]+)(\S*)/i";
// find
preg_match($yt_pre, $text, $yt_find);
$yt_loc = $yt_find[1];
// embed
$yt_rep = "<div class='youtube'><iframe src='https://www.youtube.com/embed/" . $yt_loc . "' frameborder='0' allowfullscreen class='youtube_iframe'></iframe></div>";
// replace
preg_replace($yt_pre, $yt_rep, $text);