首页 >后端开发 >php教程 >PHP随机函数怎么写

PHP随机函数怎么写

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原创
2016-06-23 13:59:05935浏览

<?php$yanse_random=array("#fc9630","#000"):for($i=0;$i<7;$i++){	$left=(550+15*$i);echo'<div class="round_yi'.$i.' jueduidingwei yuandian" style="left:'.$left.'px; top:585px;"></div>';}?>


div设置随机颜色 从$yanse_random 2种颜色随机选 怎么写呢 


回复讨论(解决方案)

rand(min,max)

<?php$yanse_random=array("#fc9630","#000");for($i=0;$i<7;$i++){    $left=(550+15*$i);    $color=$yanse_random[mt_rand(0,1)];	echo'<div class="round_yi'.$i.' jueduidingwei yuandian" style="left:'.$left.'px; top:585px;color:'.$color.'">demo</div>';}?>

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn