$string = [31m this is some text [1m this is some text in the same color, but BRIGHTER [0m this is some text in the same color, but back to dim.
[31m sets the colour. I need to scan the sttring, replace the [31m with the html colour code that [31m matches, and store the [31m in a variable so that when the scan reaches [1m (which means: change existing color to existing color but brighter) I can check which color was last changed, and select the appropriate html color code for the brighter version of the color.
I have no problem using a str_replace on the [31m but the problem occurs when the [1m appears.
I think something like this should work, but I cannot find an "instr" function.
for ($i = 0; $i < sizeof($string); $i++) {
if instr("[", $string)
for ($i2 = 0; $i2 < sizeof($colors); $i2++) {
if instr($colors[i2], $string, $i)
replace ("[1;" + $colors[i2], htmlbright[i2], $string, 1 //1 times)
$lastcolor = i2;
else
replace ("[", $htmlbright[$lastcolor], $string, 1)
}
$i2=0;
where $colors is an array containg all [# codes and htmlbright is the html equivalent codes.
Any help appreciated.