for ($i = 1; $i <= 10; $i++) { if ($i == 5) { break; // exit the loop when $i equals 5 } echo $i . " "; } // Output: 1 2 3 4