PLEASE NOTE: I already know about the PHP highlight function "for PHP Code". I need to use BBcode because the site will support many languages, Actionscript, Javascript, CSS, PHP, ASP, etc.
So for each language I want to have a BBcode for it like
[*ASP][*/ASP]
[*PHP][*/PHP]
[*CSS][*/CSS]
[*JS][*/JS]
(without the * of course)
So when a user submits a post, and the $postBody variable looks like say:
Code: Select all
$postBody = 'Some text describing the code.
Then some more text almost a paragraph worth.
OK here's an example:
[*PHP]$foo = 45;
for ( $i = 1; $i < $foo; $i++ )
{
echo "$foo<br />\n";
--$foo;
}[*/PHP]
Now more text yadda yadda.
Did you like my example,
yadda yadda yadda.';Code: Select all
$lang = 'PHP'; <-- I need it to recognize the tag name
$source = 'the code here'; <-- take only the code between the tagsCode: Select all
$geshi = new GeSHi($source, $lang, $path);I can echo it back like this:
Code: Select all
echo $geshi->parse_code();How do I grab the data already inside $postBody in the BBcode tags along with the tag identifier in those 2 variables... then... after I pass it to GeSHi, echo $postBody with the GeShI formatted code?