LoginSignup
5
5

More than 5 years have passed since last update.

PHPでswitch文中のcontinueはbreakと同じ・・・なので

Last updated at Posted at 2013-05-08

意外と知らない人多いのでメモ。。

⬇これだと全件まわしちゃうけど、、

for ( $i = 1; $i <= 5; $i++ ) {
  switch ( $i ) {
    case 3:
      continue; # =break
  }
  var_dump( $i );
}

=> 1,2,3,4,5

⬇こうすればOK。(continue 2とする)

for ( $i = 1; $i <= 5; $i++ ) {
  switch ( $i ) {
    case 3:
      continue 2;
  }
  var_dump( $i );
}

=> 1,2,4,5

5
5
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
5
5