实用的6位颜色代码生成小程序,适用于标签云中,以下是我
最近在做标签云的效果中,生成了随机的颜色效果,在此使用一下:
<?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; } $color = randomColor(); echo ‘<span style="color:‘.$color.‘">Random color: ‘.$color.‘</span>‘; ?>
PHP生成随机的HTML颜色代码,布布扣,bubuko.com
原文地址:http://jyb2014.blog.51cto.com/9155315/1542062