Source Code:
(back to article)
<?php $outer = ['a', 'b', 'c']; $inner = ['x', 'y', 'z', 'target', 'w']; foreach ($outer as $value) { foreach ($inner as $innerValue) { echo $innerValue . PHP_EOL; // Output the current value of $innerValue if ($innerValue == 'target') { break 2; // Exit both loops when the target value is found } } } echo 'Done!'; // Output a message after the loops complete
Result:
Report an issue