次の関数を使用してYouTubeリンクをビデオとして表示していますが、問題は、複数のビデオを置き換える方法がわからないため、1つだけに制限するにはどうすればよいですか?
phpコード:
function embedYoutube($text)
{
$pattern = '/[\\?\\&]v=([^\\?\\&]+)/';
$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);
}