ahi tienes .. usando preg_replace es facil ..
Código PHP:
Ver original<?php
$string = "OXXXXXXXXXXXXXXOOOOOOOOOOOOOXXXXXXXXXXOOOO";
$string = preg_replace('/(X+)/','<span style="color:red">$1</span>', $string); $string = preg_replace('/(O+)/','<span style="color:green">$1</span>', $string); echo $string;
?>
saludos!