View Single Post
Old 07-09-2002, 04:30 PM   PM User | #8
firepages
Super Moderator


 
Join Date: May 2002
Location: Perth Australia
Posts: 3,901
Thanks: 5
Thanked 79 Times in 78 Posts
firepages will become famous soon enough
this => http://www.firepages.org/stuff/ereg.php throws a parse error on one of the lines, but the rest appear to work??

PHP Code:
<?
$col
=array(
x=>"<font color=\"#006400\">",b=>"<font color=\"#00008B\">",
c=>"<font color=\"#008B8B\">",g=>"<font color=\"#006400\">",
m=>"<font color=\"#8B008B\">",r=>"<font color=\"#8B0000\">",
w=>"<font color=\"#808080\">",y=>"<font color=\"#808000\">",
B=>"<font color=\"#0000FF\">",C=>"<font color=\"#OOFFFF\">",
G=>"<font color=\"#00FF00\">",M=>"<font color=\"#FF00FF\">",
R=>"<font color=\"#FF0000\">",W=>"<font color=\"#FFFFFF\">",
Y=>"<font color=\"#FFFF00\">",D=>"<font color=\"#636363\">");

$yaks=file('amazing.txt');
foreach(
$yaks as $str){
$str=eregi_replace("\{([a-z]{1})","</font>{\".\$col[\\1].\"",$str);
eval(
"echo \"<font color=navy>$str\";");
echo 
"<br />";
}
?>
lol just noticed that both the forum and the highlight_string() function strip a '\' from the code

$col[\1] should read $col[\\1]
__________________
resistance is...

MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

Last edited by firepages; 07-09-2002 at 04:34 PM..
firepages is offline   Reply With Quote