Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 1.20 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. array_rand() array to string?
  2. $hex = array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");
  3.        
  4. $random_color = array_rand($hex,6);
  5.        
  6. echo implode($random_color);
  7.        
  8. echo $hex[$random_color[0]];
  9. echo $hex[$random_color[1]];
  10. echo $hex[$random_color[2]];
  11. echo $hex[$random_color[3]];
  12. echo $hex[$random_color[4]];
  13. echo $hex[$random_color[5]];
  14.        
  15. $hex = array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");
  16. shuffle($hex);
  17.  
  18. echo sub_str(implode('',$hex),0,6);
  19.        
  20. printf('%02x%02x%02x',mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));
  21.        
  22. printf('%06x',mt_rand(0,16777215));
  23.        
  24. implode('', array_rand(array_flip($hex), 6));
  25.        
  26. dechex(mt_rand(0, 0xFFFFFF));
  27.        
  28. $random_color = array_rand(array_flip($hex), 6);
  29.        
  30. <?php
  31. $hex = array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");
  32. shuffle($hex);
  33. echo implode(array_slice($hex, 0, 6));
  34.        
  35. substr(md5(time()),-6);
  36.        
  37. substr(md5(uniqid()),-6);
  38.        
  39. $result = "";
  40. $random_color = array_rand($hex, 6);
  41. foreach ($random_color as $randomIndex) {
  42.   $result = $result . $hex[$randomIndex];
  43. }
  44.        
  45. $color = '';
  46. while(strlen($c) < 6) {
  47.     $color .= sprintf("%02X", mt_rand(0, 255));
  48. }
  49.        
  50. mt_srand((double)microtime()*1000000);