this is php 怎么会这么短呢?

How would this short this is php code?

$szam[1]=rand(1,95);
$szam[2]=rand(1,95);

if($szam[1]!=$szam[2]){
$szam[3]=rand(1,95);

    if($szam[3]!=$szam[2]and $szam[3]!=$szam[1]){
    $szam[4]=rand(1,95);

        if($szam[4]!=$szam[3]and$szam[4]!=$szam[2]and$szam[4]!=$szam[1]){
        $szam[5]=rand(1,95);

            if($szam[5]!=$szam[4]and$szam[5]!=$szam[3]and$szam[5]!=$szam[2]and$szam[5]!=$szam[1]){
                $lottoszam=$szam[1].",".$szam[2].",".$szam[3].",".$szam[4].",".$szam[5];
            }
            else{$szam[5]=rand(1,95);}
        }
        else{$szam[4]=rand(1,95);}
    }
    else{$szam[3]=rand(1,95);}
}
else{$szam[2]=rand(1,95);}

您可以使用 in_array() 函数来实现。 PHP Manual in_array() funcion

将你的随机数保存在数组中并像这样检查它

if (in_array($random, $numbers)) {
  //exist
}