Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PHP: for loop with break
// If "i" is equal to 10, break out of the loop and ignore the echo statement below.
<?php
for($i=0; $i<=10; $i++) {
echo $i;
if($i==10) {
break;
}
echo ", ";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment