Jump to content

Recommended Posts

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***

Link to comment
https://forums.phpfreaks.com/topic/215129-recognize-a-youtube-link-in-a-string/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.