Heim >Backend-Entwicklung >PHP-Tutorial >PHP随机函数怎么写

PHP随机函数怎么写

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 13:59:05961Durchsuche

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

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn