lundi 23 février 2015

why php rand() function gives some time empty?

Hello When I try to use rand() function than it's give sometime empty like



// I want random value between 0-5000 , want 500 random value
for ($i=0; $i < 500; $i++) {
$randNo = rand(0, 5000);

if (in_array($randNo, $randArray)) {
$randNo = InfiniteLoop($randArray ,$length_sec);
}
array_push($randArray,$randNo);
}
sort($randArray);


After that i print that array give some empty value.



//output
Array ( [0] => [1] => 523 [2] => 824 [3] ....so on )




Aucun commentaire:

Enregistrer un commentaire