我有以下文字
"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 "
我想要的是将上面的网址替换为
"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];
但我不知道如何替换网址
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>
请帮忙谢谢