note 78754 deleted from function.highlight-string by felipe
| From: | felipe@php.net | Date: | Sun, 16 Dec 2007 11:34:25 +0000 |
| Subject: | note 78754 deleted from function.highlight-string by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-133666@lists.php.net to get a copy of this message | ||
Note Submitter: mosquito dot tyler at gmail dot com
Reason: 1
----
This is an addition to dark_messenger84's highlight script.
I added a line to make the script allow blank lines in code.
<?php
function print_php_code($str, $type) {
switch ($type) {
case "text":
$str = highlight_string($str, true);
break;
case "file":
$str = highlight_file($str, true);
break;
}
$str = explode("<br />", $str);
echo "<div>";
echo "<ol>\n";
foreach ($str as $line => $syntax) {
$syntax = (strlen($syntax) >1) ? $syntax : " ";
echo "<li><code>" . $syntax . "</code></li>";
}
echo "</ol>\n";
echo "</div>";
}
?>