For loops and foreach in PHP are two commonly used functions, for is used for numbers, and foreach is used in array traversal.
| The code is as follows |
Copy Code |
PHP current loop is 1, loop from inside to outside increments, break default is 1, such as jumping out of the 2nd layer loop for ($i =0; $i <3; $i + +) { foreach (Array () as $val) { foreach (Array () as $val) { echo "1-layer loop "; Break 2; Jump out of the 2nd layer loop } echo "2-layer loop "; } echo "3-layer Loop "; } Results: 1-Layer Loop 3-Layer Loop 1-Layer Loop 3-Layer Loop 1-Layer Loop 3-Layer Loop |
http://www.bkjia.com/PHPjc/628950.html www.bkjia.com true http://www.bkjia.com/PHPjc/628950.html techarticle For loops and foreach in PHP are two commonly used functions, for is used for numbers, and foreach is used in array traversal. The code below copies the code//php the current loop is 1, loop by ...