note 23844 added to function.highlight-string
| From: | webmaster@php.net | Date: | Tue, 30 Jul 2002 06:05:13 +0000 |
| Subject: | note 23844 added to function.highlight-string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-33964@lists.php.net to get a copy of this message | ||
Hi guys heres this function i made based on your posts up here: this will highlight all code between
[source] and [/source]. I made it for articles and tutorials where collaborators post their stuff
and need some code into it.
I hope its useful to you
function color_source($string){
$array_contenido = explode("[source]",$string);
$final = $array_contenido[0];
for($i = 1;$i <= count($array_contenido);$i++){
$array_contents = explode("[/source]",$array_contenido[$i]);
ob_start();
highlight_string($array_contents[0]);
$array_contents[0] = ob_get_contents();
ob_end_clean();
$final .='<br><font face="Courier new, Courier, Mono"
size=3>'.$array_contents[0]."</font><br>".$array_contents[1];
}
return $final;
}
Bye ;-)
http://www.solophp.com
--
http://www.php.net/manual/en/function.highlight-string.php
http://master.php.net/manage/user-notes.php?action=edit+23844
http://master.php.net/manage/user-notes.php?action=delete+23844
http://master.php.net/manage/user-notes.php?action=reject+23844