note 39356 added to function.highlight-string

From: Date: Sun, 25 Jan 2004 20:35:35 +0000
Subject: note 39356 added to function.highlight-string
Groups: php.notes 
Request: Send a blank email to php-notes+get-64173@lists.php.net to get a copy of this message
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; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.highlight-string.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+39356 Delete -- http://master.php.net/manage/user-notes.php?action=delete+39356&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+39356&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#64173) next »