Código PHP:
numberrange = 10;
numbersyouneed = 5;
moviecounter=1;
counter1 = 1;
counter2 = 0;
firsttime = "yes";
while (counter1 <= numbersyouneed) {
eval("randommovie"+counter1) = random(numberrange);
if (eval("randommovie"+counter1) eq 0){
while (eval("randommovie"+counter1) eq 0){
eval("randommovie"+counter1) = random(numberrange);
}
}
if (firsttime eq "no"){
while (counter2 <> counter1){
if (eval("randommovie"+counter1) eq eval("randommovie"+counter2)){
while (eval("randommovie"+counter1) eq eval("randommovie"+counter2)){
eval("randommovie"+counter1) = random(numberrange);
}
counter2--;
}
if (eval("randommovie"+counter1) == eval("randommovie"+counter2) ){
counter2--;
}
counter2++;
}
}
counter1++;
counter2=1;
firsttime="no";
}