note 39274 deleted from function.highlight-string by aidan
| From: | aidan@php.net | Date: | Sun, 26 Sep 2004 13:46:08 +0000 |
| Subject: | note 39274 deleted from function.highlight-string by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-77363@lists.php.net to get a copy of this message | ||
Note Submitter: feha at vision dot to
----
I liked Marc's function ...
I modified a bit for my need ... (it might be of use for others too ...)
//original Marc Giombetti - www.giombetti.com
//modified by Femi Hasani - www.vision.to
function highlight_code($code){
$code2 = stripslashes($code);
$split = split("\n", $code2);
$mv = count($split);
/*for design reasons */
if($mv < 100){
$width = "15";
}elseif($mv < 1000){
$width = "22";
}elseif($mv < 10000){
$width = "30";
}else{
$width = "15";
}
/*--------------------*/
$source_code = "<table bgcolor=\"#FFFFFF\" cellspacing=\"0\"
width=\"100%\">";
$code2 = highlight_string($code2, true);
for($i = 0; $i < $mv; $i++){
$t = $i + 1;
$source_code .= "<tr><td bgcolor=#FFFFE1 width=$width><div
align=right><font face=\"verdana\"
size=\"1\">".$t."</font></div></td>";
if($t < 2)
{
$source_code .= "<td style=\"padding-left: 5px\"
rowspan=\"10000\" valign=\"top\">".$code2."</td>";
}
$source_code .= "</tr>";
}
$source_code .="</table>";
return $source_code;
}