{% else-1 %}
Подсветка PHP BBcode

                        
function php_bbcode($text)  
{
$text = preg_replace_callback('#\[php\](.*?)\[/php\]#si',
create_function('$matches', '
$matches[1] = htmlspecialchars_decode($matches[1]);
$matches[1] = (stripos($matches[1], "<?php") === false)? "<?php \r\n".$matches[1] : $matches[1];
$matches[1] = highlight_string($matches[1], 1);

$br_num = substr_count($matches[1], "<br />");

$numeric[] = "<table cellpadding=\"0px\" cellspacing=\"0px\" border=\"0\"><tr><td style=\"font-size:13px; border-right:#999999 dashed 1px; padding-right:5px; font-family:\'Courier New\', Courier, monospace; text-align:right; vertical-align:top;\">";

for($i=1; $i<=$br_num + 1; $i++)
{
$numeric[] = $i."<br />";
}

$numeric[] = "</td><td style=\"font-size:13px; padding-left:3px; vertical-align:top; white-space:nowrap;\">".$matches[1];

$numeric[] = "</td></tr></table>";

$matches[1] = implode("", $numeric);

$result = "<div style=\"border:#999999 dashed 1px; margin: 5px 20px 5px 20px; padding:5px;\"><a href=\"http://www.php.net\" target=\"_blank\" style=\"color:#333333; font-weight:bold;\">PHP</a><br /><br />".$matches[1]."</div>";

return $result;'),
$text);

return $text;
}
0 19 0
Без комментариев...