note 54215 added to function.highlight-string

From: Date: Mon, 27 Jun 2005 14:12:01 +0000
Subject: note 54215 added to function.highlight-string
Groups: php.notes 
Request: Send a blank email to php-notes+get-91023@lists.php.net to get a copy of this message
- line numbers are unmarkable - predefined functions are linked to php.net - Coloring tags are not cutted at the end of each row (e.g. /* \n */ ) <?function showCode($code) { $html = highlight_string($code, true); $html = str_replace("\n", "", $html); $rows = explode("<br />", $html); $row_num = array(); $ii = array(); $i = 1; foreach($rows as $row) { if($i < 10) { $i = "0".$i; } $temprow = "$row\n"; $temprow = ereg_replace( "([a-z,_]+) *</font><font color=\"#007700\">\(", "<a href=\"http://www.php.net/\\1\" target=\"blank\">\\1</a></font><font color=\"#007700\">(", $temprow); $row_num[]=ereg_replace( "function </font><font color=\"#0000BB\"><a href=\"http://www.php.net/([a-z,_]+)\" target=\"blank\">([a-z]+)</a>" ,"function </font><font color=\"#0000BB\">\\1", $temprow); $ii[]=$i; $i++; } $iii=($i-1)*11; return "<div style=\"position:absolute; left:0px; top:0px; width:100%; z-index:2;\">" ."<table style=\"border:0px #000000 solid\" cellspacing=0 cellpadding=0 height=1><tr>" ."<td width=\"40\" valign=\"bottom\" align=\"left\"></td><td width=\"*\" valign=\"top\" align=\"left\">" ."<pre>".implode($row_num)."\n </pre></td></tr></table></div>" .'<div style="position:absolute; left:0px;top:0px; width:20px;z-index:1; border-right:1px solid black;">' .'<table style="border:0px #000000 solid" cellspacing=0 cellpadding=0 height=1><tr>' .'<td width="*" valign="top" align="left"><pre>'.implode("\n",$ii).'</pre> </td></tr></table></div>'; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.highlight-string.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+54215 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54215&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54215&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54215&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54215&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54215&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54215&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+54215&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#91023) next »