次のテキストがあります
"I made this video on my birthday. All of my friends are here in party. Click play to video the video
http://www.youtube.com/watch?v=G3j6avmJU48&feature=g-all-xit "
私が欲しいのは、これを上記のURLに置き換えることです
"I made this video on my birthday. All of my friends are here in party. Click play to video the video
<iframe width="853" height="480" src="http://www.youtube.com/embed/G3j6avmJU48" frameborder="0" allowfullscreen></iframe> "
次のスクリプトで上記の URL から YouTube ビデオ ID を取得できることはわかっています。
preg_match("#(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=v\/)[^&\n]+(?=\?)|(?<=v=)[^&\n]+|(?<=youtu.be/)[^&\n]+#", $word, $matches);
$youtube_id = $matches[0];
しかし、URLを置き換える方法がわかりません
http://www.youtube.com/watch?v=G3j6avmJU48&feature=g-all-xit
に
<iframe width="853" height="480" src="http://www.youtube.com/embed/G3j6avmJU48" frameborder="0" allowfullscreen></iframe>
助けてくださいありがとう