php获取随机颜色代码
( 更新:10-20 加入收藏)
方法一(完全随机颜色):
方法二(取现有数组中颜色代码进行随机):<?php
function randColor(){
$colors = array();
for($i = 0;$i<6;$i++){
$colors[] = dechex(rand(0,15));
}
return implode('',$colors);
}
?>
<?php echo '<span style="color: #'.randColor().'">#'.randColor().'</span>';?>
<?php
function randColor(){
$colors=array('5CB85C','428BCA','FF6600','D9534F','B37333','00ABA9');//随机数组中颜色代码
$show_color = array_rand($colors, 1);
return $colors[$show_color];
}
?>
<?php echo '<span style="color: #'.randColor().'">#'.randColor().'</span>';?>
上一篇:网站底部显示运行多少天代码
下一篇:纯js实现文字自动变色效果