Results: 1580
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
➤ The break statement can be used to jump out of a loop.
// This example jumps out of the loop when a is equal to 5:
for ($a = 0; $a <= 10; $a++) {
  if ($a == 5) {
    break;
  }
  echo "The number is: $a \n";
} 
/* outputs:  The number is: 0 
             The number is: 1
             The number is: 2
             The number is: 3
             The number is: 4
*/


// We print the elements of the array until the value is equal to "Audi".
$cars = array("BMW","Porsche","Audi","Mercedes-Benz");
foreach ($cars as $val) {
	if ($val == "Audi") {
		break;
	}
	echo "$val \n";
}
/* outputs:  BMW
             Porsche
*/
by Levani Makhareishvili
2 years ago
0
PHP
Loops
1
➤ The continue statement breaks one iteration (in the loop), if a specified condition occurs, and continues with the next iteration in the loop.
// This example skips the value of 2
for ($a = 0; $a < 4; $a++) {
  if ($a == 2) {
    continue;
  }
  echo "The number is: $a \n";
} 
/* outputs:  The number is: 0 
	     The number is: 1 
	     The number is: 3
*/


// We print array elements by omitting "Audi".
$cars = array("BMW","Audi","Porsche");
foreach ($cars as $val) {
	if ($val == "Audi") {
		continue;
	}
	echo "$val \n";
}
/* outputs:  BMW
             Porsche
*/
by Levani Makhareishvili
2 years ago
1
PHP
Loops
1
by nikoloz nachkebia
2 years ago
0
PHP
String functions
1
easy and logical
by nikoloz nachkebia
2 years ago
0
PHP
math functions
1
by nikoloz nachkebia
2 years ago
0
PHP
Case Sensitivity
1
by დავით ქუთათელაძე
2 years ago
0
PHP
if else statement
1
by დავით ქუთათელაძე
2 years ago
0
PHP
else if statement
1
by დავით ქუთათელაძე
2 years ago
0
PHP
user defined functions
1
by nikoloz nachkebia
2 years ago
0
PHP
PHP For loop
1
by nikoloz nachkebia
2 years ago
0
PHP
"break" Statement
1
Results: 1580