|
|
|
ทำไม random แล้ว ข้อมูลยังซ้ำกันอยู่ละคับ ผิดตรงไหนหรอครับผม |
|
|
|
|
|
|
|
............................................________
....................................,.-'"...................``~.,
.............................,.-"..................................."-.,
.........................,/...............................................":,
.....................,?......................................................,
.................../...........................................................,}
................./......................................................,:`^`..}
.............../...................................................,:"........./
..............?.....__.........................................:`.........../
............./__.(....."~-,_..............................,:`........../
.........../(_...."~,_........"~,_....................,:`........_/
..........{.._$;_......"=,_......."-,_.......,.-~-,},.~";/....}
...........((.....*~_......."=-._......";,,./`..../"............../
...,,,___.`~,......"~.,....................`.....}............../
............(....`=-,,.......`........................(......;_,,-"
............/.`~,......`-...................................../
.............`~.*-,.....................................|,./.....,__
,,_..........}.>-._...................................|..............`=~-,
.....`=~-,__......`,.................................
...................`=~-,,.,...............................
................................`:,,...........................`..............__
.....................................`=-,...................,%`>--==``
........................................_..........._,-%.......`
...................................,
|
|
|
|
|
Date :
2014-01-06 22:50:55 |
By :
itpcc |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ถ้าเป็นผมเขียน คงจะประมานนี้ คับ
<?php
function getRandom($low, $height,$arr_check){
$thisran = rand($low, $height);
$key = "".array_search($thisran, $arr_check);
if("" != $key){
return getRandom($low, $height,$arr_check);
}else {
return $thisran;
}
}
$low= 0;
$height= 9;
//echo $thisran = rand($low, $height);
$arr_val = array();
for ( $i=0;$i<5;$i++ ){
$ran_val = getRandom($low, $height,$arr_val);
$arr_val[]=$ran_val;
}
print_r($arr_val);
?>
ผิดผลาดไง ขออภัยด้วยคับ
|
|
|
|
|
Date :
2014-01-07 15:51:39 |
By :
gumix |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|