note 32572 added to function.highlight-file
| From: | tsunaquackHATESPAM at rack1 dot php dot net | Date: | Sat, 31 May 2003 23:53:55 +0000 |
| Subject: | note 32572 added to function.highlight-file | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-49504@lists.php.net to get a copy of this message | ||
I have recently upgraded to php 4.3.2 and it seems that highlight_file now returns a single line
without any LF (I mean \n)
That would nicely fix it + display the line numbers using the right number of digits all the way and
on-the-fly in an HTML table
<table border="0">
<tr><td valign="top"><code>
<?php
ob_start();
highlight_file('THE_FILE_YOU_WANT_TO_HL.PHP');
$buffer = ob_get_contents();
ob_end_clean();
$buffer = str_replace('<br />', '<br />'."\n", $buffer);
$nb = substr_count($buffer, "\n");
$l = strlen((string) $nb);
for($i = 1; $i <= $nb; $i++) echo str_pad($i, $l, '0', STR_PAD_LEFT).':<br
/>'."\n"
?>
</code></td>
<td valign="top" nowrap><?php echo $buffer; ?></td>
</table>
----
Manual Page -- http://www.php.net/manual/en/function.highlight-file.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32572
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32572&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32572&report=yes