not PHP programmer needs help
Posted: Fri Oct 20, 2006 8:35 am
Hello,
On my website I have a code block that retrieve and render information about Game Server
The script works Ok except one little detail:
Server name may contain color codes. I need to remove those codes or (which will be great!) replace with real color
the color code is 4 byte lohg 1st byte is escape char (chr(27)) and then coming 3 bytes of RGB
for example chr(27) . chr(255) . chr(1) . chr(1) means RED
I need some function that will accept as parameter a string with color codes and return the same string without any formatting.
so actually it should look for chr(27) and replace it and tree following chars with empty string.
here is sample of input string
and here is desired output
Or if possible this:
Please note that 00 doesn't used in color codes so BLACK color isn't "totaly" BLACK but 99% grey '#010101'
I don't know PHP syntax to accomplish this task
I appreciate your help
On my website I have a code block that retrieve and render information about Game Server
The script works Ok except one little detail:
Server name may contain color codes. I need to remove those codes or (which will be great!) replace with real color
the color code is 4 byte lohg 1st byte is escape char (chr(27)) and then coming 3 bytes of RGB
for example chr(27) . chr(255) . chr(1) . chr(1) means RED
I need some function that will accept as parameter a string with color codes and return the same string without any formatting.
so actually it should look for chr(27) and replace it and tree following chars with empty string.
here is sample of input string
Code: Select all
ÿ=TAG=ÿServer nameCode: Select all
=TAG=Server nameCode: Select all
<font color="#FF0101">=TAG=</font><font color="#0101FF">Server name</font>I don't know PHP syntax to accomplish this task
I appreciate your help