I use the following code to replace youtube urls to embed links in order to display them as videos. But I have come to a problem where I can't view videos from links having more parameters other than ?v=video_code
php code:
function embedYoutube($text)
{
$pattern = '|http://www\.youtube\.com/watch\?.*?\bv=([^ ]+)|';
$replacement = '<div style="width:100%;float:left;margin-top:15px;margin-bottom:15px;"><iframe width="570" height="315" src=http://www.youtube.com/embed/$1 frameborder="0" allowfullscreen></iframe></div>';
return preg_replace($pattern, $replacement, $text, 1);
}