/    Sign up×
Community /Pin to ProfileBookmark

How to insert Youtube Videos

I have created a forum and I am still adding different functions to it. I would like to give my users the ability to add Youtube links that would play directly in my forum. Does anyone have a script or have any suggestions on how to go about coding this in php. I coded the entire forum in php. I didnt want to use the software because I wanted my forum to be completely unique. Any help or suggestions would be great.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@mccoauthorAug 30.2012 — Well I have this function I found that turns the links into <a href but now instead of printing the hyperlink it is printing the html in the forum. Here is the function I found if anyone can help me figure out how to have it show up as a hyperlink instead of printing the <a href... that would be great.

[code=php]

function make_url($str) {
$msg = ' ' . $str;
$msg = preg_replace("#(^|[n ])([w]+?://[^ "nrt<]*)#is", "$1'<a href="$2" target="_blank">$2</a>'", $msg);
$msg = preg_replace("#(^|[n ])((www|ftp).[^ "tnr<]*)#is", "$1'<a href="http://$2" target="_blank">$2</a>'", $msg);
$msg = preg_replace("#(^|[n ])([a-z0-9&-_.]+?)@([w-]+.([w-.]+.)*[w]+)#i", "$1'<a href="mailto:$2@$3">$2@$3</a>'", $msg);
$msg = substr($msg, 1);

return($msg);
[/code]
Copy linkTweet thisAlerts:
@abiabiahAug 31.2012 — Here is the code, may be it can work for you:

[CODE]<?php
preg_match(
'/[\?\&]v=([^\?\&]+)/',
'http://www.youtube.com/watch?v=OzHvVoUGTOM&feature=channel',
$matches
);
// $matches[1] should contain the youtube id
?>
[/CODE]


also you can follow developers guide from Google.
×

Success!

Help @mcco spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.21,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...