note 33956 added to function.highlight-string
| From: | marc at NOSPAM dot giombetti dot com | Date: | Fri, 11 Jul 2003 22:17:42 +0000 |
| Subject: | note 33956 added to function.highlight-string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-51941@lists.php.net to get a copy of this message | ||
There are already some functions for numbering and highliting a string containging PHP sourcecode on
this site, but they were buggy or wasted recouces. I hope this snippet fits your needs.
function my_highlight($text){
$text2 = stripslashes($text);
$split = split("\n", $text2);
$mv = count($split);
/*for design reasons */
if($mv < 100){
$width = "14";
}elseif($mv < 1000){
$width = "22";
}elseif($mv < 10000){
$width = "30";
}else{
$width = "14";
}
/*--------------------*/
echo "<table bgcolor=\"#90ab83\" cellspacing=\"0\"
width=\"100%\">";
$text2 = highlight_string($text2, true);
for($i = 0; $i < $mv; $i++){
$t = $i + 1;
echo "<tr><td bgcolor=#7C9B6D width=$width><div
align=right><font face=\"verdana\"
size=\"1\">".$t."</font></div></td>";
if($t < 2)
{
echo "<td style=\"padding-left: 5px\" rowspan=\"10000\"
valign=\"top\">".$text2."</td>";
}
echo "</tr>";
}
echo"</table>";
}
Yours Sincerely
Marc Giombetti - www.giombetti.com
----
Manual Page -- http://www.php.net/manual/en/function.highlight-string.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33956
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33956&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33956&report=yes