I want to store my generated random numbers into php array
<?php
function no_repeats($source=null)
{
static $reserve = null;
static $backup = null;
if(is_array($source))
{
$backup = $reserve = $source;
shuffle($reserve);
return;
}
if(count($reserve)==0)
{
$reserve = $backup;
shuffle($reserve);
}
return array_shift($reserve);
}
$cars = array
(
array(0,0,0,0,0,0,0,0,0),
array(0,0,0,0,0,0,0,0,0),
array(0,0,0,0,0,0,0,0,0)
);
no_repeats(range(1,90));
for($i=0; $i<15; $i++) {
$r = no_repeats().'<br>';
echo $r;
}
echo '<br>';
echo '<table class="tg">';
echo "TICKET";
foreach( $cars as $car )
{
echo '<tr>';
foreach( $car as $key )
{
echo '<td>'.$key.'</td>';
}
echo '</tr>';
}
echo '</table>';
?>
In my code i used function no_repeats
to generate random numbers and created an array
$cars = array ( array(0,0,0,0,0,0,0,0,0), array(0,0,0,0,0,0,0,0,0), array(0,0,0,0,0,0,0,0,0) );
finally i want to replace my array values with random numbers which are generated by function function no_repeats
Aucun commentaire:
Enregistrer un commentaire