I\'m trying to generate random HTML colors in PHP, but I\'m having trouble getting them to look similar, or in the same family. Is there some function I can use to generate
Another short and simple version: change the mt_rand(X, Y) values in order to generate desired colour range: (0, 255) - full range; (180, 255) - pastel palette; (0, 100) - dark palette; etc...
function gen_color(){
mt_srand((double)microtime()*1000000);
$color_code = '';
while(strlen($color_code)<6){
$color_code .= sprintf("%02X", mt_rand(0, 255));
}
return $color_code;
}