note 31583 deleted from function.highlight-string by didou

From: Date: Sat, 16 Aug 2003 23:46:14 +0000
Subject: note 31583 deleted from function.highlight-string by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-54513@lists.php.net to get a copy of this message
Note Submitter: webmaster@freetimeprojects.com ---- This is my way to highlight a string... If you got a big string with some pieces of php-code in it, it leaves all your text as it is made up with your stylesheets or whatever except for the php code. So it doesn't put your normal text between those <code></code> tags. NOTE: you'll have to put your php-code between [php][/php] tags if you want to use this function. function phpHighlight($input) { $text = spliti("\[php\]|\[\/php\]",$input); for($i = 0; $i < count($text); $i++) { if(ereg("(<\?php)(.*)(\?>)",$text[$i])) { ob_start(); highlight_string($text[$i]); $text[$i] = ob_get_contents(); ob_end_clean(); } else { $text[$i] = nl2br(htmlspecialchars($text[$i])); } } $text = implode("",$text); return $text; } Hope this saves someone some work... ;-) Robert.

« previous php.notes (#54513) next »