Hello here is my function to make working colors prefix from Call of Duty. Prefix for color is for example ^1 = red
But this code looks like doesn't work on the newest php.
function colorize( $s ) {
$s = htmlSpecialChars( $s );
$t = $s;
global $numtags;
global $add;
$a = array( "red", "#000", "#a8e61d", "#fff200", "#0000d1", "#00c9cd", "#cb00ce", "#696164", "#eb93bb", "#dcdcdc" );
for( $i = 0; $i < count( $a ); $i++ ) $s = str_replace( '^^' . $i . $i, '<span style="color:' . $a[ $i ] . '";">', $s );
for( $i = 0; $i < count( $a ); $i++ ) $s = str_replace( '^' . $i, '<span style="color:' . $a[ $i ] . '";">', $s );
$spans = preg_match_all( '/\^[0-9]/U', $t, $matches );
for( $i = 1; $i <= $numtags; $i++ ) $add .= '</span>';
return $s . $add;
}