Created
February 7, 2016 11:30
-
-
Save mauryaratan/27deb4a6ba5824542a64 to your computer and use it in GitHub Desktop.
Generate a random color string 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
<?php | |
function random_color_value() { | |
return str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT ); | |
} | |
function random_color() { | |
return random_color_value() . random_color_value() . random_color_value(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment