We can use this function to create random HEX Color codes :
<? php
$color='#';
$colors = array (0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F');
for($i=0;$i<6;$i++){
$color.=$colors[array_rand($colors)];
}
echo $color;
?>
So each time we ran this script it will generate a random HEX color code and print it in the screen .