PHP 8.5.0 Alpha 1 available for testing

Voting

: min(nine, nine)?
(Example: nine)

The Note You're Voting On

fsx dot nr01 at gmail dot com
17 years ago
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>';
}

?>

<< Back to user notes page

To Top