Andy: Zufallsystem - Script in Ordnung?

Beitrag lesen

<?php
SESSION_START();

print "LIDS: $lids<br>";

$max = 5;

$exp_lids = explode("|", $lids);
$count = count($exp_lids)-1;

mt_srand ((double)microtime()*1000000);
function zufall ()
{
 global $max, $id, $exp_lids, $lid, $count;
 $id = mt_rand(0,$max);

for ($i=0; $i <= $count; $i++)
 {
  $lid = $exp_lids[$i];
  print "$lid == $id<br>";
  if ($lid == $id) zufall();
 }

return $id;
}

print "$count == $max<br>";
if ($count != $max)
{
 $id = zufall();
 $lids = $id."|".$lids;
 $_SESSION['lids'] = $lids;
}

if ($id == '') print "ende";
else print "ID: $id<br>";
?>

was spricht hier noch dagegen? ausser global?