PHP interesse |
|
Als je dit nou eens als function colorcoding($code) maakt:
<?php
function colorcoding($code){
$code = str_replace("<br>", "", $code);
$code = str_replace("<br />", "", $code);
$code = str_replace(">", ">", $code);
$code = str_replace("<", "<", $code);
$code = str_replace("&", "&", $code);
$code = str_replace(""", "\"", $code);
$code = str_replace('$', '\$', $code);
$code = str_replace('\n', '\\\\n', $code);
$code = str_replace('\r', '\\\\r', $code);
$code = str_replace('\t', '\\\\t', $code);
$code = trim($code);
$code = stripslashes($code);
ob_start();
highlight_string($code);
$regel = ob_get_contents();
ob_end_clean();
$regel = explode("<br />", $regel);
$code = "";
$code .= "<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">";
$code .= "<tr><td width=\"20\" align=\"right\"><code>";
for($i = 0; $i < (count($regel)); $i++){
$t = $i;
$t++;
$code .= $t."<br />";
}
$code .= "</code></td><td width=\"100%\">";
for($i = 0; $i < (count($regel)); $i++){
$t = $i;
$t++;
$code .= $regel[$i]."<br />";
}
$code .= "</td></tr></table>";
$code .= "</table>";
return $code;
}
?>
<?php function colorcoding($code){ $regel = explode("<br />", $regel); $code = ""; $code .= "<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">"; $code .= "<tr><td width=\"20\" align=\"right\"><code>"; for($i = 0; $i < (count($regel)); $i++){ $t = $i; $t++; $code .= $t."<br />"; } $code .= "</code></td><td width=\"100%\">"; for($i = 0; $i < (count($regel)); $i++){ $t = $i; $t++; $code .= $regel[$i]."<br />"; } $code .= "</td></tr></table>"; $code .= "</table>"; return $code; } ?>
dan werkt hij wel, je kan natuurlijk zelf aanpassen hoe je je code wilt weergeven.. ($code .= "<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">";
$code .= "<tr><td width=\"20\" align=\"right\"><code>"; ) die regels aanpassen dus |