---
# System prepended metadata

title: ＊例題＊用陣列做出威力彩號亂碼
tags: [PHP基礎課程]

---

---
title: ＊例題＊用陣列做出威力彩號亂碼
tags: PHP基礎課程
---

用陣列做出威力彩號亂碼
===
```php=
echo "<h3>第一區</h3>";
$lotto=[];
while(count($lotto)<6){
    $num=rand(1,38);
    if(!in_array($num, $lotto)){
        $lotto[]=$num;
    }
}
echo "開出順序:";
for($i=0;$i<count($lotto);$i++){
    echo $lotto[$i].",";
}
echo "<br>大小順序:";
sort($lotto);//照順序大小排序陣列
for($i=0;$i<count($lotto);$i++){
    echo $lotto[$i].",";
}
echo "<h3>第二區</h3>";
echo rand(1,8);
```

