1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【php】1~5のランダムな数字を取得し、金賞、銀賞、銅賞の表示分けをせよ

Last updated at Posted at 2021-05-10
<?php
$place = rand(1,5); // 順位を1〜5の範囲でランダムに作られた数字を$placeに代入
echo "placeの中身:".$place."\n";
   if ($place == 1) {
          echo "金賞";
        } elseif ($place == 2) {
           echo "銀賞";
        } elseif ($place == 3) {
           echo "銅賞";
        } else {
           echo $place."位";
        }
?>

順位が1位だったら「金賞」と表示し、
順位が2位だったら「銀賞」と表示し、
順位が3位だったら「銅賞」と表示し、
それ以外だったら「○位」と表示するプログラムを作成せよ。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?