Jump to content
php.lv forumi

3 dazhaadi randomaa gjenereeti skaitlji


spoks

Recommended Posts

Shitaa vari gjenereet arii vairaak kaa 3 (pie esoshajiem nosacijumiem max(10)) random ciparus noraadot tos for() ciklaa..

 

<?
$arr = array();
for($i=1;$i<4;$i++) {
$r = rand(1,10);
while(in_array($r,$arr)) { $r = rand(1,10);  }
$arr[$i] = $r;
}
print_r($arr);
?>

Link to comment
Share on other sites

×
×
  • Create New...