note 51762 added to function.highlight-string
| From: | support at superhp dot de | Date: | Sun, 10 Apr 2005 11:58:13 +0000 |
| Subject: | note 51762 added to function.highlight-string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-87784@lists.php.net to get a copy of this message | ||
With this function you can highlight php code with line numbers:
<?php
function highlight_php($string)
{
$Line = explode("\n",$string);
for($i=1;$i<=count($Line);$i++)
{
$line .= " ".$i." <br>";
}
ob_start();
highlight_string($string);
$Code=ob_get_contents();
ob_end_clean();
$header='<table border="0" cellpadding="0" cellspacing="0"
width="95%" style="border-style: solid; border-width:1px; border-color: white black
black white">
<tr>
<td width="100%" colspan="2" style="border-style: solid;
border-width:1px; border-color: white; background-color: #99ccff; font-family:Arial; color:white;
font-weight:bold;">Php-Code:</td>
</tr>
<tr>
<td width="3%" valign="top" style="background-color: #99ccff;
border-style: solid; border-width:1px; border-color:
white;"><code>'.$line.'</code></td>
<td width="97%" valign="top" style="background-color:
white;"><div style="white-space: nowrap; overflow:
auto;"><code>';
$footer=$Code.'</div></code></td>
</tr>
</table>';
return $header.$footer;
} ?>
----
Manual Page -- http://www.php.net/manual/en/function.highlight-string.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51762
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51762&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51762&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51762&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51762&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51762&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51762&report=yes
Search -- http://master.php.net/manage/user-notes.php