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