Page 2 of 2
Posted: Wed Jun 09, 2004 12:17 pm
by markl999
ok, this worked for me (with multiple code blocks):o
Code: Select all
$output = preg_replace('|\[div](.*?)\[/div]|ise',"highlight_string('\\1',true)", $row['body']);
echo $output;
edit I ended up doing the following to sort the newlines/br's out.
Code: Select all
$output = preg_replace('|\[div](.*?)\[/div]|ise',"str_replace('<br />', '', highlight_string('\\1',true))", $row['body']);
echo nl2br($output);
Posted: Wed Jun 09, 2004 2:41 pm
by Steveo31
Yeah, that worked for me too, but stuff was parsed. I'm not at home now, but code with variables and whatnot were problematic.
Posted: Wed Jun 09, 2004 4:03 pm
by markl999
Yeah, the one above is slightly different that previos ones (notice the different quotes). I too was getting parse errors as it was trying to parse the variables that was in the code from the db, but the above solved it (did for me anyway

)
Posted: Sat Jun 26, 2004 4:37 pm
by Steveo31
I've been out of this game for a while, and this worked great. Thanks Mark.
Only thing I can't figure out is how to replace the [div] with <div class="innercode"></div>. This has the background like the forums here.
Posted: Wed Dec 01, 2004 4:07 pm
by Steveo31
Wahoo! Finally got it!
Code: Select all
$output = preg_replace('|\[div](.*?)\[/div]|ise',""<div class='div_code'>".highlight_string(stripslashes('\\1'),true)."</div>"", $row['body']);
echo $output;
Thanks a ton you guys!!