Created
January 30, 2015 12:44
-
-
Save fordarnold/4ccf90358ac241713d0e to your computer and use it in GitHub Desktop.
Generate a random Hex Colour Code in PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function random_color_part() { | |
return str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT); | |
} | |
function random_color() { | |
return random_color_part() . random_color_part() . random_color_part(); | |
} | |
echo random_color(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See this conversation on StackOverflow.com