note 43735 added to function.highlight-string
| From: | AlexRAustin at rn2 dot php dot net | Date: | Thu, 01 Jul 2004 18:04:21 +0000 |
| Subject: | note 43735 added to function.highlight-string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-72274@lists.php.net to get a copy of this message | ||
Makes sure that code will correspond to its line number no matter what.
<?
function color_code($code)
{
$code = $copy = substr_replace(substr_replace
(highlight_string(stripslashes($code),true),'',0,28),'',-15,15);
do
{
$range=strchr($copy, '<font ');
$tagrange=substr($range,0,strlen($range)-
strlen(strchr($range, '</font>')));
$br=strchr($tagrange, '<br />');
if (strlen($br)>0)
{
$fulltag=substr($tagrange,0,strlen($tagrange)-
strlen(strchr($tagrange, '>')));
$l_len=strlen($code)-strlen($range)+
strlen($tagrange)+6;
$tag=$fulltag.'>';
}
while (strlen($br)>0)
{
$indexarray[]=$l_len-strlen($br);
$tagarray[]=$tag;
$br=strchr($br=substr($br,6), '<br />');
}
$copy=substr($range,1);
} while (strlen($copy)>0);
$max=count($tagarray);
for ($count=0;$count<$max;$count++)
{
$code=substr_replace($code,$tagarray[$count],
($indexarray[$count]+$offby),0);
$code=substr_replace($code,'</font>',
($indexarray[$count]+$offby-6),0);
$offby+=strlen($tagarray[$count])+7;
}
$max=count($code = split('<br />', $code));
for ($count=0;$count<$max;$count++)
{
$output.='<tr><td align="right" valign="top">'.
($count+1). '.</td><td>'.$code[$count].'</td></tr>';
}
return '<table border="0" width="100%"
cellspacing="0">'.$output.'</table>';
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.highlight-string.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+43735
Delete -- http://master.php.net/manage/user-notes.php?action=delete+43735&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+43735&report=yes
Search -- http://master.php.net/manage/user-notes.php