View Single Post
Old 07-08-2002, 09:02 PM   PM User | #3
Dalsor
New Coder

 
Join Date: Jul 2002
Location: Florida, USA
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
Dalsor is an unknown quantity at this point
Trying to convert them when the PHP script parses the text document.

This is a switch from a piece of C code that I use that lists each of the codes and their correspoding font codes, the difference being, this code converts the color codes prior to the HTML being written, whereas I'm trying to write a PHP script to convert the color codes to font codes from a file that already exists.

case 'x':
sprintf( code, "<font color=""#006400"">" );
break;
case 'b':
sprintf( code, "<font color=""#00008B"">" );
break;
case 'c':
sprintf( code, "<font color=""#008B8B"">" );
break;
case 'g':
sprintf( code, "<font color=""#006400"">" );
break;
case 'm':
sprintf( code, "<font color=""#8B008B"">" );
break;
case 'r':
sprintf( code, "<font color=""#8B0000"">" );
break;
case 'w':
sprintf( code, "<font color=""#808080"">" );
break;
case 'y':
sprintf( code, "<font color=""#808000"">" );
break;
case 'B':
sprintf( code, "<font color=""#0000FF"">" );
break;
case 'C':
sprintf( code, "<font color=""#OOFFFF"">" );
break;
case 'G':
sprintf( code, "<font color=""#00FF00"">" );
break;
case 'M':
sprintf( code, "<font color=""#FF00FF"">" );
break;
case 'R':
sprintf( code, "<font color=""#FF0000"">" );
break;
case 'W':
sprintf( code, "<font color=""#FFFFFF"">" );
break;
case 'Y':
sprintf( code, "<font color=""#FFFF00"">" );
break;
case 'D':
sprintf( code, "<font color=""#636363"">" );
break;
case '{':
sprintf( code, "{" );
break;

This is the PHP script that reads and echoes the flat file sans my futile attempts to convert the strings.

<?php
$strings = file("/path/to/my/dir/nstring.dat");
foreach($strings as $line){
// before echo, loop through $line and convert codes
echo $line . "<br>";
}
?>
Dalsor is offline   Reply With Quote