note 79208 deleted from function.preg-replace-callback by ezyang
| From: | ezyang@php.net | Date: | Thu, 15 Nov 2007 21:26:20 +0000 |
| Subject: | note 79208 deleted from function.preg-replace-callback by ezyang | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-132326@lists.php.net to get a copy of this message | ||
Note Submitter: Dev
Reason: useless
----
to highlight a code between bbcode tags like [php] and [/php] with the class geshi..
<?php
$code = '[php1]echo "Hello World!";[/php1]';
echo preg_replace_callback('/\[php\](.*)\[\/php\]/s',"geshi",$code);
function geshi($matches)
{
// include geshi
$geshi = include_once("geshi/geshi.php");
$geshi = new GeSHi($matches[1],"php");
// to enable line numbers
//$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
return $geshi->parse_code();
}
?>
to download geshi go to http://qbnz.com/highlighter/downloads.php