Guest User

Untitled

a guest
Nov 22nd, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. function random_color_part() {
  2. return str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT);
  3. }
  4.  
  5. function random_color() {
  6. return random_color_part() . random_color_part() . random_color_part();
  7. }
  8.  
  9. echo random_color();
  10.  
  11. function rand_color() {
  12. return '#' . str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT);
  13. }
  14.  
  15. function rand_color() {
  16. return sprintf('#%06X', mt_rand(0, 0xFFFFFF));
  17. }
  18.  
  19. $color = substr(md5(rand()), 0, 6);
  20.  
  21. $rand = dechex(rand(0x000000, 0xFFFFFF));
  22. echo('#' . $rand);
  23.  
  24. $color = sprintf("#%06x",rand(0,16777215));
  25.  
  26. echo '#' . substr(str_shuffle('ABCDEF0123456789'), 0, 6);
  27.  
  28. $colors = array();
  29. while (true) {
  30. $color = substr(str_shuffle('ABCDEF0123456789'), 0, 6);
  31. $colors[$color] = '#' . $color;
  32. if ( count($colors) == 10000 ) {
  33. echo implode(PHP_EOL, $colors);
  34. break;
  35. }
  36. }
  37.  
  38. function randomHex() {
  39. $chars = 'ABCDEF0123456789';
  40. $color = '#';
  41. for ( $i = 0; $i < 6; $i++ ) {
  42. $color .= $chars[rand(0, strlen($chars) - 1)];
  43. }
  44. return $color;
  45. }
  46.  
  47. echo randomHex();
  48.  
  49. $hex_string = bin2hex(openssl_random_pseudo_bytes(3));
  50.  
  51. <?php echo 'rgba('.rand(0,255).', '.rand(0,255).', '.rand(0,255).', 0.73)'; ?>
  52.  
  53. $color= substr(str_shuffle('AABBCCDDEEFF00112233445566778899'), 0, 6);
Add Comment
Please, Sign In to add comment