Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Generate a random color string in PHP.
<?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
You can’t perform that action at this time.