Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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();
- function rand_color() {
- return '#' . str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT);
- }
- function rand_color() {
- return sprintf('#%06X', mt_rand(0, 0xFFFFFF));
- }
- $color = substr(md5(rand()), 0, 6);
- $rand = dechex(rand(0x000000, 0xFFFFFF));
- echo('#' . $rand);
- $color = sprintf("#%06x",rand(0,16777215));
- echo '#' . substr(str_shuffle('ABCDEF0123456789'), 0, 6);
- $colors = array();
- while (true) {
- $color = substr(str_shuffle('ABCDEF0123456789'), 0, 6);
- $colors[$color] = '#' . $color;
- if ( count($colors) == 10000 ) {
- echo implode(PHP_EOL, $colors);
- break;
- }
- }
- function randomHex() {
- $chars = 'ABCDEF0123456789';
- $color = '#';
- for ( $i = 0; $i < 6; $i++ ) {
- $color .= $chars[rand(0, strlen($chars) - 1)];
- }
- return $color;
- }
- echo randomHex();
- $hex_string = bin2hex(openssl_random_pseudo_bytes(3));
- <?php echo 'rgba('.rand(0,255).', '.rand(0,255).', '.rand(0,255).', 0.73)'; ?>
- $color= substr(str_shuffle('AABBCCDDEEFF00112233445566778899'), 0, 6);
Add Comment
Please, Sign In to add comment