code_mit_zilennummer_ausgeben.php
Quell Code
<?PHP
function lineNumber($file, $table, $print=false)
{
$content = highlight_file($file,TRUE);
$ex_line = file($file);
$lines = count($ex_line);
$length = strlen($lines);
for($x=1;$x<=$lines;$x++)
{
$ausgabe .= str_pad($x, $length, "0", STR_PAD_LEFT);
$ausgabe .= ":<br>";
}
$table = @preg_replace('/{lineNumber}/',$ausgabe,$table);
$table = @preg_replace('/{phpHighlight}/',$content,$table);
if($print === false)
{
return $table;
}
else
{
echo $table;
}
}
$table .= '<table><tr>';
$table .= '<td><code>';
$table .= '<span style="color: #AAAAAA;">{lineNumber}</span>';
$table .= '</code></td>';
$table .= '<td>{phpHighlight}</td>';
$table .= '</tr></table>';
$lineNum = lineNumber("code_mit_zilennummer_ausgeben.php",$table,true);
?>