Raul Duke
02-09-2006, 04:52 AM
I have a function here that generates hex codes for the use of inputing them into html for colors. The function works great, my problem is that sometimes the code it generates ends up a 5 digit hex code, which firefox dosn't like. Any suggestions on how I can ensure that each hex value created is two digits?
function randColor(){
$r= rand(0,255);
$g= rand(0,255);
$b= rand(0,255);
$rhex = dechex($r);
$ghex = dechex($g);
$bhex = dechex($b);
$color = $rhex . $ghex . $bhex;
return $color;
}
function randColor(){
$r= rand(0,255);
$g= rand(0,255);
$b= rand(0,255);
$rhex = dechex($r);
$ghex = dechex($g);
$bhex = dechex($b);
$color = $rhex . $ghex . $bhex;
return $color;
}