Follow Star

Control Structures #break



تأتي مع التالي .


  1. for .
  2. foreach .
  3. while .
  4. do-while .
  5. switch .

بناء الحملة = break 1 .


1
2
3
4
5
6
7
8
9
<?php
1----
2------
3--------xxx
4-------
5----------
break;

?>

1. break .


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php  
<?php

$a = array('knows1990',
             'knows1991',
             'knows1992',
             'knows1', // stop da
             'knows1993',
             'knows1994');

foreach ($a as $b) {
    if ($b == 'knows1993') {
        break;  
    }
    echo "$b<br />\n";
}

?>

2. break .


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php

$array = [ 'a', 'b', 'c', 'd', 'f' ];

foreach( $array as $value ){
    if( $value == 'one' ){
        echo "Number three was found!";

    }
      if( $value == 'a' ){
        echo "k";

    }
      if( $value == 'b' ){
        echo "n";

    }
      if( $value == 'c' ){
        echo "w";
///xxxxxxxxxxxxxxxxxxxxxxxxxx
break;
///xxxxxxxxxxxxxxxxxxxxxxxxxx
    }
      if( $value == 'd' ){
        echo "s";

    }
        if( $value == 'd' ){
        echo "1";

    }
}

?>
Control Structures      
if      
else      
elseif/else if      
Alternative syntax for control structures      
while      
do-while      
for      
foreach      
break      
continue      
switch      
declare      
return      
require      
include      
require_once      
include_once      
goto      

Tags:

Categories:

Updated:

Comments