-
-
Save yokesharun/0abae7fefbccc94df76e to your computer and use it in GitHub Desktop.
Generate Random Color in PHP
This file contains 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