iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
Honey you do realise the colour is rendered in html? The clever bit, i.e. first letter green second letter red, is done by writing code. Try it.
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
here i got it. i just wrote the code and lightly tested it. to make it fit with your program i need to now where the string thats being colored is coming from (mysql, ect.)
kkeith29
Nearly a Posting Virtuoso
1,353 posts since Jun 2007
Reputation Points: 235
Solved Threads: 195
nevermind about the customizing. i made it into a function. lets say you have words contained in the variable $string, all you would have to do is call the function "color()" with the string that needs to be colored inside the parathesis ex. "color($string)" and the colored text will echoed onto the page.
Heres the color function code:
<?php
function color($str) {
$i = 0;
while ($i < strlen($str)) {
$letters[] = substr($str, $i, 1);
$i++;
}
$colors = array(0 => '<font color="green">',1 => '<font color="red">',2 => '<font color="blue">');
$i = 0;
$c = 0;
while ($i < count($letters)) {
if ($c == 3) {
$c = 0;
}
echo $colors[$c] . $letters[$i] . '</font>';
$i++;
$c++;
}
}
?>
kkeith29
Nearly a Posting Virtuoso
1,353 posts since Jun 2007
Reputation Points: 235
Solved Threads: 195