-1

I am getting a string from database and echo it with php. There is a youtube link in this string and after i echo it i want it to be clickable. Also i want to get the youtube code which is at the end of the link. How can i make it?

Example text: This video is very interesting. Watch it at https://www.youtube.com/watch?v=kkLTxsAhURw. I loved it!

Thank you.

2 Answers2

0

Instead of echoing just the text you can echo:

<a href=".$row['YOUTUBELINK'].">".$row['YOUTUBELINK']."</a>.

This will produce a clickable link. It's hard to help you without code though.

L30
  • 3
  • 1
  • Thanks, but i want it to be like the example above. The actual link must be clickable. I dont know how to make php understand that its a link when it get the whole text from database. – Engin Erdoğan Jul 21 '14 at 08:10
0

You can get youtube code from youtube link using following script.

$youtube_link  = 'https://www.youtube.com/watch?v=kkLTxsAhURw';
$youtube_code = substr($youtube_link, strpos($youtube_link, "=") + 1);
echo $youtube_code;
Talk2Nit
  • 1,115
  • 3
  • 22
  • 38