Parsing colorcodes
| From: | Simon Fredriksson | Date: | Sun, 26 Oct 2003 17:29:11 +0000 |
| Subject: | Parsing colorcodes | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-167636@lists.php.net to get a copy of this message | ||
Hiya fellow PHP coders!
I have a problem. I need a function to parse mIRC-colorcodes with PHP. Unfortunaly, I'm not capable to do this myself (or I'm thinking too advanced or something).
The code is built like this; chr(3) starts the color formating. After that sign, a series of numbers will come. Can be one or two digits (1-15). 0-9 can have an additional zero before it, like 00-09. Each of these number represents a color.
00 = White
01 = Black
02 = Dark Blue
03 = Dark Green
04 = Red
05 = Marron
06 = Purple
07 = Orange
08 = Yellow
09 = Green
10 = Teal
11 = Cyan
12 = Blue
13 = Magenta
14 = Dark Gray
15 = Gray
Now, to make it even worse, it's possible to use a background-color for the text. This is added with a coma. So, the syntax is "X4,8String" where X is really chr(3). Red (4) String with yellow (8) background.
The colorparsing can stop when another occurance of chr(3) commes up. Also, the colorparsing ends at the end of line.
Please help me on this issue.
//Simon