Php how to exit the foreach loop break; if the break is completed by function/method processing, you can also use returnreturnd for usage. refer to the following article, although Java is used, however, some PHP syntaxes are also applicable. Brief introduction to return and PHPcodeforeach in Java (how does $ dat php exit the foreach loop?
How does php exit the foreach loop break;
------ Solution --------------------
Break
If function/method processing ends, you can also use return
For returnd usage, refer to the following article. although Java is used, some PHP syntax is also applicable.
Brief introduction to return in Java
------ Solution --------------------
PHP code
Foreach ($ data as $ row) {echo $ row; break ;}
------ Solution --------------------
PHP code
Foreach ($ array as $ key => $ value) {if ($ value = 5) break;} // This is a type. // If it is a nested loop, you can add a number using continue to implement foreach ($ array as $ key => $ value) {foreach ($ value as $ key2 => $ value2) {if ($ value = 5) continue 2 ;}}
------ Solution --------------------
Break, continue, return, exit