convert bbcode to html

Links for php scripts

Moderators: macek, egami, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 9
Joined: Fri Mar 14, 2003 7:23 pm

Post by zeep25 » Wed Jun 25, 2003 3:45 pm

if u want to change the bbcode into html... this should fix your problem :


/*This will change the [b] into <b> */

/*This will change the [/b] into </b> */

$Input = "$message";

/* This combines the new data (the html code from above) with the old data (what was already in the .txt file. */
$New = "$Input";

/* This writes everything to the .txt file and then closes up the script. */
$filename = "caption.txt";
$fp = fopen( $filename,"w");
fwrite($fp, $New, 80000);
fclose( $fp );


User avatar
New php-forum User
New php-forum User
Posts: 73
Joined: Sun May 04, 2003 4:26 am
Location: Athens

Post by mike » Fri Jul 04, 2003 6:35 pm

Some adittional convertions:

Code: Select all

$str = "Hello [color=cc3300]big [b]phpbrother[/b] this [u]is a[/u] fancy [i]test[/i][/color]";

//color convert
$str = str_replace("[color", "<font color", $str);
$str = str_replace("[/color]", "</font>", $str);

//bold,underline,italis convert
$str = str_replace("]", ">", $str);
$str = str_replace("[", "<", $str);


Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests