Community Forums

Important Notice:

Two sections of this forum are available only to registered customers. In order to receive access to the Customer Forums and ResellerCentral Forums, you must first register on these forums or login to your existing forum account. If you are an existing HostNine customer, be sure to register using the email address on file for your billing profile.

Go Back   HostNine Community Forums > H9 General Forums > Lounge / Off Topic > Web Development

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 01-12-2010, 01:50 AM
reaper reaper is offline
Junior Guru Wannabe
 
Join Date: Mar 2009
Posts: 29
Default Youtube BBcode

Ok i have built a custom news script for my site that uses BBcode. I would like to be able to embed youtube videos using the following
"[youtube]Youtube link here[/youtube]" but for some reason i can't get it to work. Here is an example of how i am doing my BBcode so if any one can edit this to work as a youtube BBcode that would be great!

$data = str_replace("[big]", "<h1>", $data);
$data = str_replace("[/big]", "</h1>", $data);
Reply With Quote
  #2  
Old 01-27-2010, 08:26 AM
H9MattR
Guest
 
Posts: n/a
Default

You could just str_replace with arrays to make the conversions much easier --

$toReplace = array("<h1>", "</h1>");
$toBeReplaced = array('[youtube]', '[/youtube]'); //Note the double-slash

$newphrase = str_replace($toReplace, $toBeReplaced, $data);

Your example should work perfectly, but what's provided above will allow you to use a single call with an array to function rather than nesting potentially hundreds of calls to str_replace.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 01:51 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.

Host Nine

Our mission began in 2006. Thousands of awesome clients later, we are now one of the most popular hosters in the world.
Most of this is because of our fantastic support. Join us, you'll be glad you did - that's a given.