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~15までの数字を繰り返し表示する

Posted at

###for文を使う

for($i=1;$i<=15;$++){
    print($i."\n");
}

###while文を使う

$i=1;
while($i<=15){
    print($i);
    print("\n");
    $i ++;
}

###foreachを使う

foreach(range(1,15) as $i){
   echo $i.'<br>';
}

繰り返しの範囲が最初から決められているのならばforeachでrangeで書くのが一番簡単かも。

1
0
1

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?