note 70456 deleted from function.highlight-string by googleguy

From: Date: Tue, 22 Oct 2013 14:59:29 +0000
Subject: note 70456 deleted from function.highlight-string by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-197277@lists.php.net to get a copy of this message
Note Submitter: vanessaschissato at gmail dot com ---- This class show a code formated. Allow options for to format. Options: highlight code and to show line number <?php class Code { function printCode($code, $high_light = 0, $lines_number = 0) { if (!is_array($code)) $code = explode("\n", $code); $count_lines = count($code); foreach ($code as $line => $code_line) { if ($lines_number) $r1 = "<span class=\"lines_number\">".($line + 1)." </span>"; if ($high_light) { if (ereg("<\?(php)?[^[:graph:]]", $code_line)) { $r2 = highlight_string($code_line, 1)."<br />"; } else { $r2 = ereg_replace("(&lt;\?php&nbsp;)+", "", highlight_string("<?php ".$code_line, 1))."<br />"; } } else { $r2 = (!$line) ? "<pre>" : ""; $r2 .= htmlentities($code_line); $r2 .= ($line == ($count_lines - 1)) ? "<br /></pre>" : ""; } $r .= $r1.$r2; } echo "<div class=\"code\">".$r."</div>"; } } ?>

« previous php.notes (#197277) next »