note 90229 added to function.highlight-file

From: Date: Sat, 11 Apr 2009 10:02:42 +0000
Subject: note 90229 added to function.highlight-file
Groups: php.notes 
Request: Send a blank email to php-notes+get-153076@lists.php.net to get a copy of this message
I get linenumbers this way... cause I don't like tables :p <? function highlight_linenumbers ($page) { // remove <code> and global <span> $code = highlight_file($page, true) ,36,-15); echo '<ol style="font-family:monospace; color:', ini_get('highlight.{default}') , ';">'; $arr = explode('<br />', $code); foreach( $arr as $line ) { // removing newline $line = substr($line, 0, -1); //empty lines if( preg_match('^(&nbsp;)*$',$line) ) $line = '&nbsp;'; // add colour from the previous line if( !empty($last_colour) ) $s = '<span style="color:'.$last_colour .'">'. $s; // Supposing we open more spans on a line than closing... let's do this properly // We have at most one currently opened span if( substr_count($line, '<span') - substr_count($line, '</span') > 0 ) { $line .= '</span>'; // Grab colour to report it on next line $last_colour = explode('<span ',$line); $last_colour = $last_colour[count($last_colour)-1]; $last_colour = substr($last_colour,strpos($last_colour,'#'),7); else $last_colour = NULL; echo '<li>',$line,"</li>\r"; } echo '</ol>'; } ?> ---- Server IP: 89.31.146.176 Probable Submitter: 82.227.37.62 ---- Manual Page -- http://www.php.net/manual/en/function.highlight-file.php Edit -- https://master.php.net/note/edit/90229 Del: integrated -- https://master.php.net/note/delete/90229/integrated Del: useless -- https://master.php.net/note/delete/90229/useless Del: bad code -- https://master.php.net/note/delete/90229/bad+code Del: spam -- https://master.php.net/note/delete/90229/spam Del: non-english -- https://master.php.net/note/delete/90229/non-english Del: in docs -- https://master.php.net/note/delete/90229/in+docs Del: other reasons-- https://master.php.net/note/delete/90229 Reject -- https://master.php.net/note/reject/90229 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#153076) next »