AviNahum Posted October 4, 2010 Share Posted October 4, 2010 hey... i found this code: $youtube_customize = "&hl=en&fs=1&color1=0x2b445c&color2=0x4c7499"; // youtube replacement: $text = preg_replace('#([\s\(\)])http://([a-z]+\.)?youtube\.com/watch\?v=([0-9a-zA-Z_\-]+)(&[^"\s\(\)<\[\.]*)?#', '$1<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/$3' . $youtube_customize . '"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>' . '<embed src="http://www.youtube.com/v/$3' . $youtube_customize . '" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>', $text); this code recognize a youtube link in a string and convert it to embed code to watch it directly in my website... for example: text text text text text text in this string, the link will be converted to embed code... this code works fine... but in my website, im using an editor, and is some cases this editor put links into <A> tags, for example, this link: will be converted to this: <a href="http://www.youtube.com/watch?v=4WRVwZTS4qU&feature=channel">http://www.youtube.com/watch?v=4WRVwZTS4qU&feature=channel</a> but now, this link cant be converted to a youtube embed video... anyone knows how i can check if the link located between <A> tags? Thanks! ***sorry for my english*** Quote Link to comment https://forums.phpfreaks.com/topic/215129-recognize-a-youtube-link-in-a-string/ Share on other sites More sharing options...
AviNahum Posted October 9, 2010 Author Share Posted October 9, 2010 anyone? Quote Link to comment https://forums.phpfreaks.com/topic/215129-recognize-a-youtube-link-in-a-string/#findComment-1120650 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.