Monkuar Posted November 25, 2011 Share Posted November 25, 2011 $txt = preg_replace( "#\[yt\]http://www.youtube.com/watch?v=(.+?)\[/yt\]#is", '<embed src="http://www.youtube.com/v/\\1" type="application/x-shockwave-flash" wmode="transparent" width="512" height="313" allowfullscreen="true" />', $txt ); Okay this is my code just for inserting it into HTML, the problem is whenever I try to use: [yt]http://www.youtube.com/watch?v=l1G7TJD6Xu0[/yt] On my form to enter it does not work? But if I use $txt = preg_replace( "#\[yt\](.+?)\[/yt\]#is", '<embed src="http://www.youtube.com/v/\\1" type="application/x-shockwave-flash" wmode="transparent" width="512" height="313" allowfullscreen="true" />', $txt ); [yt]l1G7TJD6Xu0[/yt] It works. But I want to use the full URL of the youtube, so I don't want my users to copy/paste just the "l1G7TJD6Xu0" Code , any help? Thank you Quote Link to comment https://forums.phpfreaks.com/topic/251772-php-youtube-bbcode-url/ Share on other sites More sharing options...
Laash Posted November 26, 2011 Share Posted November 26, 2011 Don't think you can use the full url with the embed tag, just the l1G7TJD6Xu0 which is the video's id on youtube. I would suggest to use youtube's new iframe code anyway. Quote Link to comment https://forums.phpfreaks.com/topic/251772-php-youtube-bbcode-url/#findComment-1291394 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.