-3

这是我的 php 脚本:当我尝试将值返回到 $total 并随后回显函数 generate_random_3 时,在某些情况下它不会生成任何数字,请帮忙

<?php
    function generate_random_3(){

        for($x=0; $x<3; $x++){
            $random[] = rand(1, 9);
        }
        list($first, $second, $third) = $random;

        if($first!=$second AND $first!=$third AND $second!=$third AND $first!=0){
            $total = $first.$second.$third;
            return $total;
            }else{
            generate_random_3();
            }
    }
    echo generate_random_3();
?>
4

2 回答 2

1
function generate_random_3() {
  return rand(100,999);
}

echo generate_random_3();
于 2013-02-12T13:40:08.427 回答
0

either way....

$number1 = rand(0,365);
$number2 = rand(0,365);
$number3 = rand(0,365);


echo $number1 . " " . $number2 . " " . $number3;
于 2013-02-12T13:39:51.647 回答