Home > Backend Development > PHP Tutorial > PHP随机函数怎么写

PHP随机函数怎么写

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-23 13:59:05
Original
937 people have browsed it

<?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>';}?>
Copy after login


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>';}?>
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template