\n"; //output without line numbers of word wrapping
$code = str_replace(" ", " ", $code); //replace non-breaking spaces with normal ones
$code = str_replace(" ", " ", $code); //replace double-spaces with ' '
$lines = explode("
", $code); //break into lines
$nlines = count($lines)-1; //count number of lines
$lnlength = strlen($nlines); //count the number of digits in this number
$output = "";
for ($i = 0; $i < $nlines; ++$i) //for each line add a line number and put the break back in
$output .= $lines[$i]."
\n ".str_pad((2+$i), $lnlength, '0', STR_PAD_LEFT)." ";
$output .= $lines[$i]; //attach final line
$coloured = " ".str_pad('1', $lnlength, '0', STR_PAD_LEFT)." ".substr($output, 6); //insert line number of the first line
echo "\n";
}
?>