note 83820 added to function.highlight-string

From: Date: Fri, 13 Jun 2008 11:14:28 +0000
Subject: note 83820 added to function.highlight-string
Groups: php.notes 
Request: Send a blank email to php-notes+get-140407@lists.php.net to get a copy of this message
Here is an improved version of the code highlighter w/ linenumbers from 'vanessaschissato at gmail dot com' - http://nl.php.net/manual/en/function.highlight-string.php#70456 <?php function printCode($source_code) { if (is_array($source_code)) return false; $source_code = explode("\n", str_replace(array("\r\n", "\r"), "\n", $source_code)); $line_count = 1; foreach ($source_code as $code_line) { $formatted_code .= '<tr><td>'.$line_count.'</td>'; $line_count++; if (ereg('<\?(php)?[^[:graph:]]', $code_line)) $formatted_code .= '<td>'. str_replace(array('<code>', '</code>'), '', highlight_string($code_line, true)).'</td></tr>'; else $formatted_code .= '<td>'.ereg_replace('(&lt;\?php&nbsp;)+', '', str_replace(array('<code>', '</code>'), '', highlight_string('<?php '.$code_line, true))).'</td></tr>'; } return '<table style="font: 1em Consolas, \'andale mono\', \'monotype.com\', \'lucida console\', monospace;">'.$formatted_code.'</table>'; } ?> ---- Server IP: 89.248.170.61 Probable Submitter: 81.205.66.149 ---- Manual Page -- http://www.php.net/manual/en/function.highlight-string.php Edit -- https://master.php.net/note/edit/83820 Del: integrated -- https://master.php.net/note/delete/83820/integrated Del: useless -- https://master.php.net/note/delete/83820/useless Del: bad code -- https://master.php.net/note/delete/83820/bad+code Del: spam -- https://master.php.net/note/delete/83820/spam Del: non-english -- https://master.php.net/note/delete/83820/non-english Del: in docs -- https://master.php.net/note/delete/83820/in+docs Del: other reasons-- https://master.php.net/note/delete/83820 Reject -- https://master.php.net/note/reject/83820 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#140407) next »