<!-- 全部的球放進盒子裡,隨機挑出六個 -->
<?php
$min = 1;
$max = 42;
$total = 6;
// 用PHP二支函式即可做出樂透猜數字
$a_ball = range($min, $max);
$a_box = array_rand($a_ball, $total);
// 顯示
$str = '';
foreach($a_box as $one) //想像一下;取這盒子內的一顆球,共六次
{ $str .= '<img src="images/' . $a_ball[$one] . '.jpg" width="81" height="81" />';
}