I\'m working on a project where I need to generate an undefined number of random, hexadecimal color codes…how would I go about building such a function in PHP?
As of PHP 5.3, you can use openssl_random_pseudo_bytes():
$hex_string = bin2hex(openssl_random_pseudo_bytes(3));