lotto.php(我正在努力将随机数转化为“票”)

时间:2013-09-14 07:00:21

标签: php html arrays post

我迷路了。我正在努力为我的lotto.php随机数字。第一个是我的HTML:

<textarea name="ticket" rows="20" cols="20"></textarea>

如何将“票证”带到标准的php格式?

// Set the min/max
$numbers = array_fill(1,47,0);
// array-slice
$numbers = range(1, 47);
shuffle($numbers);
$numbers = array_slice($numbers, 0, 6);
print_r($numbers);

另外,我也必须有$ _POST。

1 个答案:

答案 0 :(得分:1)

利用PHP的implode()

<?php
$numbers = array_fill(1,47,0);
// array-slice
$numbers = range(1, 47);
shuffle($numbers);
$numbers = array_slice($numbers, 0, 6);
//print_r($numbers);
$lottonum = implode(" ", $numbers); // Space as seperator
echo $lottonum;

输出:

  

45 24 6 25 17 28