note 99002 deleted from function.highlight-string by danbrown
| From: | danbrown@php.net | Date: | Wed, 21 Jul 2010 19:03:48 +0000 |
| Subject: | note 99002 deleted from function.highlight-string by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-171024@lists.php.net to get a copy of this message | ||
Note Submitter: Zahlii
----
Yet another snippet for Syntax-Highlighting with line-numbers
<style type="text/css">
body {
font-family:Consolas;
font-size:14px;
}
</style>
<?php
function display($c) {
$lines = explode("\n",$c);
$i=1;
$c2 = '<ol>';
foreach($lines as $line) {
if($i%5==0) $style='font-weight:bold;';
else $style = 'color:#666;';
$line_o = highlight_string("<?php ".$line,true);
$line_n =
str_replace(array("<?php ","<code>","</code>"),"",$line_o);
$c2 .= '<li style="'.$style.'"><span
style="font-weight:normal;">'.$line_n."</span></li>";
$i++;
}
echo $c2.'</ol>';
}
?>
display("< ?php echo 'Hello World!'; ?>;");