Created
January 17, 2012 01:51
-
-
Save yesidays/1624048 to your computer and use it in GitHub Desktop.
code.jobs - Hexadecimal random color - PHP
This file contains hidden or 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
<?php | |
function randomColor() { | |
$str = '#'; | |
for($i = 0 ; $i < 6 ; $i++) { | |
$randNum = rand(0 , 15); | |
switch ($randNum) { | |
case 10: $randNum = 'A'; break; | |
case 11: $randNum = 'B'; break; | |
case 12: $randNum = 'C'; break; | |
case 13: $randNum = 'D'; break; | |
case 14: $randNum = 'E'; break; | |
case 15: $randNum = 'F'; break; | |
} | |
$str .= $randNum; | |
} | |
return $str; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment