사이트 내 전체검색
PHP
break
로빈아빠
https://cmd.kr/php/209 URL이 복사되었습니다.

본문

break는 현재 루프에서 빠져 나가는 명령이다.

break에는 숫자 옵션을 줄 수 있는데, 이것은 한번에 빠져 나갈 제어 구조의 수를 의미한다.

  1
  2 $i = 0;
  3 while ($i < 10) {
  4    if ($arr[$i] == "stop") {
  5        break;  /* You could also write 'break 1;' here. */
  6    }
  7    $i++;
  8 }
  9
 10 /* Using the optional argument. */
 11
 12 $i = 0;
 13 while ( ++$i ) {
 14    switch ( $i ) {
 15    case 5:
 16        echo "At 5<br>\n";
 17        break 1;  /* Exit only the switch. */
 18    case 10:
 19        echo "At 10; quitting<br>\n";
 20        break 2;  /* Exit the switch and the while. */
 21    default:
 22        break;
 23    }
 24 }
 25

출처 : http://qdata.co.kr/bo/bbs/board.php?bo_table=pht&wr_id=45

댓글목록

등록된 댓글이 없습니다.

PHP
871 (3/18P)

Search

Copyright © Cmd 명령어 3.141.45.76