note 39356 deleted from function.highlight-string by aidan
| From: | aidan@php.net | Date: | Sun, 26 Sep 2004 13:46:02 +0000 |
| Subject: | note 39356 deleted from function.highlight-string by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-77362@lists.php.net to get a copy of this message | ||
Note Submitter: Malcolm
----
I liked the other highlight functions but I found that on some browsers the line numbers aren't
lined up properly.
This is the function I wrote for my user postings, uses a table for perfect line number <->
code alignment.
<?php
function phpHighlight($code){
$code = "<?php\n".$code."\n?>";
$code = stripslashes($code);
$code = highlight_string($code, true);
$code = explode('<br />', $code);
$text = "<div style='margin:0px 5% 0px 5%;'>PHP:<hr /><table
style='padding:0px; border-spacing: 0px 0px;'>";
for($x=0;$x<sizeof($code);$x++)
$text .= "<tr><td style='font-family:Verdana; font-size:10px;
vertical-align:middle; background-color:#FFFFE1;'>".
($x+1)."</td><td><div style='margin:0px 5px 0px 5px;'>".
$code[$x]."</div></td></tr>";
$text .= "</table><hr /></div>";
return $text;
}
?>