note 43735 deleted from function.highlight-string by aidan

From: Date: Sun, 26 Sep 2004 14:24:24 +0000
Subject: note 43735 deleted from function.highlight-string by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-77402@lists.php.net to get a copy of this message
Note Submitter: Alex R Austin ---- 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>'; } ?>

« previous php.notes (#77402) next »