I have following text
"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 "
What i want is to replace this above url to
"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> "
I know we can get youtube video id from above url in following script
preg_match("#(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=v\/)[^&\n]+(?=\?)|(?<=v=)[^&\n]+|(?<=youtu.be/)[^&\n]+#", $word, $matches);
$youtube_id = $matches[0];
But I dont know how to replace url
http://www.youtube.com/watch?v=G3j6avmJU48&feature=g-all-xit
to
<iframe width="853" height="480" src="http://www.youtube.com/embed/G3j6avmJU48" frameborder="0" allowfullscreen></iframe>
Please help Thanks