Generate random colors

All your question about php
Post Reply
mister_v
Posts: 188
Joined: Thu Mar 04, 2010 9:19 pm

Generate random colors

Post by mister_v »

Question,

is there a special function to get a random color.
chris
Site Admin
Posts: 194
Joined: Mon Jul 21, 2008 9:52 am

Re: Generate random colors

Post by chris »

I don't know of a special function,
but this is a function I use.

function random_color()
{
$r=rand(128,255);
$g=rand(128,255);
$b=rand(128,255);
$color=dechex($r).dechex($g).dechex($b);
return "#".$color;
}
Post Reply