note 92697 modified in function.highlight-file by danbrown
| From: | danbrown@php.net | Date: | Tue, 04 Aug 2009 17:00:48 +0000 |
| Subject: | note 92697 modified in function.highlight-file by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-159091@lists.php.net to get a copy of this message | ||
Here's a great function I found to add numbers to your highlighted code:
<?php
function highlight_num($file)
{
$lines = implode(range(1, count(file($file))), '<br />');
$content = highlight_file($file, true);
echo '
<style type="text/css">
.num {
float: left;
color: gray;
font-size: 13px;
font-family: monospace;
text-align: right;
margin-right: 6pt;
padding-right: 6pt;
border-right: 1px solid gray;}
body {margin: 0px; margin-left: 5px;}
td {vertical-align: top;}
code {white-space: nowrap;}
</style>';
echo "<table><tr><td
class=\"num\">\n$lines\n</td><td>\n$content\n</td></tr></table>";
}
highlight_num(__FILE__);
?>
--was--
Here's a great function I found to add numbers to your highlighted code:
function highlight_num($file)
{
$lines = implode(range(1, count(file($file))), '<br />');
$content = highlight_file($file, true);
echo '
<style type="text/css">
.num {
float: left;
color: gray;
font-size: 13px;
font-family: monospace;
text-align: right;
margin-right: 6pt;
padding-right: 6pt;
border-right: 1px solid gray;}
body {margin: 0px; margin-left: 5px;}
td {vertical-align: top;}
code {white-space: nowrap;}
</style>';
echo "<table><tr><td
class=\"num\">\n$lines\n</td><td>\n$content\n</td></tr></table>";
}
highlight_num(__FILE__);
http://php.net/manual/en/function.highlight-file.php