convert bbcode to html

Links for php scripts

Moderators: egami, macek, gesf

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

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

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);

11:16am up 404 days, 2 users, load average: 148.68, 143.45, 132.6

Mike Vassileiou
[Systems Administrator / PHP Developer]

PHP/MySQL Manual:

Post Reply