I need to color text with 2 or 3 random colors. How can I do this in PHP or JavaScript?
$color = str_pad(sprintf("%x%x%x", rand(0,255), rand(0,255), rand(0,255)),6,rand(0,9));
echo '<span style="color:'.$color.'">Random Color</span>';
Provides random #<Red><green><blue> color
This should do the trick:
function getRandomColour() {
return 'red'; // chosen by fair dice roll
// guaranteed to be random
}
Courtesy of XKCD, for those of you who are new around here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With