<?php
session_start();
$min = 1; $max = 14; $count = 4;
function getRandomNumbers($count, $min, $max, &$pool)
{
if(!isset($pool) || count($pool) < $count)
{
$pool = range($min, $max);
shuffle($pool);
}
for($c=$count;$c>0;$c--) $numbers[] = array_pop($_SESSION['pool']);
return $numbers;
}
echo '<p>4 Numbers: '.implode(', ', getRandomNumbers($count, $min, $max, $_SESSION['pool'])).'</p>';
|