Devo scegliere 5 numeri compresi tra 1 e 10 random doversi...c'è un modo apparte controllare tramite cicli if abbastanza lunghini?
Grazie.
Devo scegliere 5 numeri compresi tra 1 e 10 random doversi...c'è un modo apparte controllare tramite cicli if abbastanza lunghini?
Grazie.
GdR Online - http://lenar.it/
Yesterday is history. Tomorrow is mystery.
Today is a gift. That's why it's called the present
potresti fare cosi:
Codice PHP:
<?php
/* riempio l'array con i valori possibili*/
$v=array();
for($i=1; $i<=10; $i++){
$v[]=$i;
}
/*estraggo 5 indici dell'array random*/
$keys = array_rand($v, 5);
/* stampo i valori estratti */
foreach($keys as $k ){
echo "{$v[$k]}\n";
}
?>
oppure:
codice:$temp=range(1,10); srand((double)microtime()*123456789); shuffle($temp); for($i=0;$i<5;$i++) echo array_shift($temp)." ";
think simple think ringo
i numeri sarebbero in
$k[1],$k[2],$k[3],$k[4],$k[5] ?
Grazie.
GdR Online - http://lenar.it/
Yesterday is history. Tomorrow is mystery.
Today is a gift. That's why it's called the present
Ok ok...funza.
Grazie!
GdR Online - http://lenar.it/
Yesterday is history. Tomorrow is mystery.
Today is a gift. That's why it's called the present